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) {
       
        Alert alert = new Alert(AlertType.NONE);
        alert.setAlertType(type);
        alert.setTitle(title);
        alert.setHeaderText(null);
        alert.setContentText(text);
       
       
        ((Stage) alert.getDialogPane().getScene().getWindow()).setAlwaysOnTop(onTop);
       
        return alert.showAndWait().orElse(ButtonType.CANCEL);
    }
public static buttontype showalert(alerttype type, string title, string text, boolean ontop) { alert alert = new alert(alerttype.none); alert.setalerttype(type); alert.settitle(title); alert.setheadertext(null); alert.setcontenttext(text); ((stage) alert.getdialogpane().getscene().getwindow()).setalwaysontop(ontop); return alert.showandwait().orelse(buttontype.cancel); }