/**
     * Returns the pressed Button of the alert.
     * That can be used to in a condition, eg.:
     * showAlert(AlertType.CONFIRMATION, "OK?", "Is it ok?") == ButtonType.OK
     * 
     * @param type  the alert type
     * @param title the title of the alert
     * @param text  the text of the alert
     * @param onTop the alert "modality"; true if the alert should be always 
     *               on top, false otherwise
     * @return      the button type (depends on the alert type)
     */
public static ButtonType showAlert(AlertType type, String title, String text, boolean onTop) {
        // NOTE: alert must be (re-)created everytime, otherwise the following HACK doesn't work!
        Alert alert = new Alert(AlertType.NONE);
        alert.setAlertType(type);
        alert.setTitle(title);
        alert.setHeaderText(null);
        alert.setContentText(text);
        // HACK: since it is not possible to set the owner of an javafx alert to
        //       a swing frame, we use the following approach to set the modality!
        ((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(onTop);
        // if no button was pressed, the dialog got canceled (ESC, close)
        return alert.showAndWait().orElse(ButtonType.CANCEL);
    }
public static ButtonType showAlert(AlertType type, String title, String text, boolean onTop) {
// NOTE: alert must be (re-)created everytime, otherwise the following HACK doesn't work!
Alert alert = new Alert(AlertType.NONE);
alert.setAlertType(type);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(text);
// HACK: since it is not possible to set the owner of an javafx alert to
// a swing frame, we use the following approach to set the modality!
((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(onTop);
// if no button was pressed, the dialog got canceled (ESC, close)
return alert.showAndWait().orElse(ButtonType.CANCEL);
}
public static ButtonType showAlert(AlertType type, String title, String text, boolean onTop) {
// NOTE: alert must be (re-)created everytime, otherwise the following HACK doesn't work!
Alert alert = new Alert(AlertType.NONE);
alert.setAlertType(type);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(text);
// HACK: since it is not possible to set the owner of an javafx alert to
// a swing frame, we use the following approach to set the modality!
((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(onTop);
// if no button was pressed, the dialog got canceled (ESC, close)
return alert.showAndWait().orElse(ButtonType.CANCEL);
}
public static ButtonType showAlert(AlertType type, String title, String text, boolean onTop) {
// NOTE: alert must be (re-)created everytime, otherwise the following HACK doesn't work!
Alert alert = new Alert(AlertType.NONE);
alert.setAlertType(type);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(text);
// HACK: since it is not possible to set the owner of an javafx alert to
// a swing frame, we use the following approach to set the modality!
((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(onTop);
// if no button was pressed, the dialog got canceled (ESC, close)
return alert.showAndWait().orElse(ButtonType.CANCEL);
}