Used for Fatal Errors. JavaFX Alert Dialog - Java JavaFX

Java examples for JavaFX:Dialog

Description

Used for Fatal Errors. JavaFX Alert Dialog

Demo Code


import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;

public class Main{
    /**//from   w w  w.j  a v  a2 s .c  om
     * Used for Fatal Errors. Log the error before use.
     * @param headerText
     * @param contentText
     */
    public static void showAlertAndExit(String headerText,
            String contentText) {
        Alert alert = new Alert(AlertType.ERROR);

        alert.setHeaderText(headerText);
        alert.setContentText(contentText);

        alert.showAndWait();

        Platform.exit();
    }
}

Related Tutorials