delete JavaFX Dialog - Java JavaFX

Java examples for JavaFX:Dialog

Description

delete JavaFX Dialog

Demo Code


import javafx.scene.control.Alert;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import java.util.Optional;
import java.util.ResourceBundle;

public class Main{
    public static boolean deleteDialog() {
        ResourceBundle bundle = BundleUtil.getInstance().getBundle();

        Alert dialog = new Alert(Alert.AlertType.WARNING);
        dialog.setTitle(bundle.getString("warningTitle"));
        dialog.setHeaderText(bundle.getString("deleteHeader"));
        dialog.setContentText(bundle.getString("deleteWarning"));

        ButtonType buttonYes = new ButtonType(bundle.getString("yesOption"));
        ButtonType buttonNo = new ButtonType(bundle.getString("noOption"),
                ButtonBar.ButtonData.CANCEL_CLOSE);

        dialog.getButtonTypes().setAll(buttonYes, buttonNo);
        Optional<ButtonType> selectedOption = dialog.showAndWait();

        return selectedOption.isPresent()
                && selectedOption.get() == buttonYes;
    }/*from w  ww .  j a va 2s .  c o  m*/
}

Related Tutorials