Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

cancel javafx stage exit request

public void start(Stage stage) throws Exception {
    FXMLLoader ldr = new FXMLLoader(getClass()
                .getResource("Application.fxml"));
    Parent root = (Parent) ldr.load();
    appCtrl = (ApplicationController) ldr.getController();

    Scene scene = new Scene(root);

    stage.setScene(scene);
    stage.show();

    scene.getWindow().setOnCloseRequest(new EventHandler<WindowEvent>() {
        public void handle(WindowEvent ev) {
            if (!appCtrl.shutdown()) {
                ev.consume();
            }
        }
    });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cancel #javafx #stage #exit #request
ADD COMMENT
Topic
Name
9+6 =