JavaFX Alerts and their size

I have made the following workaround:

Alert alert = new Alert(AlertType.INFORMATION, "Content here", ButtonType.OK);
alert.getDialogPane().setMinHeight(Region.USE_PREF_SIZE);
alert.show();

So the window will resize automatically according to the content.

Leave a Comment