JavaFX: How to set minimum dialog width/size

JavaFX tip: To set the minimum width of a dialog, such as a TextInputDialog, use the setMinWidth method on the dialog’s dialog pane, like this:

val d = new TextInputDialog("")
d.setTitle("Open URL")
d.setHeaderText("Open a URL")
d.getDialogPane.setMinWidth(500)  <-- solution

I don’t have time to share an image here, but I just used this code and it does set the minimum dialog width to 500 pixels, as desired.

As you can imagine, there are other methods available on the JavaFX DialogPane to set the minimum width, height, and size, as well as maximum size values. As you can imagine, the key to this solution is knowing to call getDialogPane on the dialog.

Also, note that I show the solution in Scala, but the code is easily converted to Java.