Java examples for JavaFX:Dialog
JavaFX dialog Error
import javafx.event.Event; import javafx.scene.Node; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.stage.Window; public class Main{ public static void dialogError(String msg, Event event) { dialogError(msg, getWindowFromEvent(event)); }/* www . j a va2s . co m*/ public static void dialogError(String msg, Window window) { Alert alert = new Alert(AlertType.ERROR); alert.initOwner(window); alert.setTitle("Error"); alert.setHeaderText(null); alert.setContentText(msg); alert.show(); } public static Window getWindowFromEvent(Event e) { return ((Node) e.getSource()).getScene().getWindow(); } }