import javafx.application.Application; import static javafx.application.Application.launch; import javafx.scene.control.Alert; import javafx.scene.control.DialogEvent; import javafx.stage.Stage; /** * * @author lans */ public class DialogSizeFail extends Application { private volatile Alert alert; public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { alert = new Alert(Alert.AlertType.ERROR); alert.setOnShown(this::onShown); alert.setOnCloseRequest(this::onClosing); alert.show(); } public void onClosing(DialogEvent event) { System.out.println("Dialog is closing."); System.out.println("Alert height: " + alert.getHeight() + ", DialogPane height: " + alert.getDialogPane().getHeight()); } public void onShown(DialogEvent event) { System.out.println("Dialog is shown."); System.out.println("Alert height: " + alert.getHeight() + ", DialogPane height: " + alert.getDialogPane().getHeight()); } }