How do I create and show common dialogs (Error, Warning, Confirmation) in JavaFX 2.0? I can't find any "standard" classes like Dialog
, DialogBox
, Message
or something.
Recently released JDK 1.8.0_40 added support for JavaFX dialogs, alerts, etc. For example, to show a confirmation dialog, one would use the Alert class:
Alert alert = new Alert(AlertType.CONFIRMATION, "Delete " + selection + " ?", ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.showAndWait();
if (alert.getResult() == ButtonType.YES) {
//do stuff
}
Here's a list of added classes in this release: