How to create and show common dialog (Error, Warning, Confirmation) in JavaFX 2.0?


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.

This question is tagged with dialog javafx-2

~ Asked on 2011-11-29 11:28:50

The Best Answer is


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);

if (alert.getResult() == ButtonType.YES) {
    //do stuff

Here's a list of added classes in this release:

~ Answered on 2015-03-05 20:38:54


EDIT: dialog support was added to JavaFX, see

There were no common dialog support in a year 2011. You had to write it yourself by creating new Stage():

Stage dialogStage = new Stage();

VBox vbox = new VBox(new Text("Hi"), new Button("Ok."));
vbox.setPadding(new Insets(15));

dialogStage.setScene(new Scene(vbox));;

~ Answered on 2011-11-29 12:09:13

Most Viewed Questions: