On my app, there is a primary window and a secondary for some changes. When the user want to close the app (= primary window) i want to ask from the user the confirmation for closing the secondary window of the changes to avoid being lost of changes.
This code is on my main class.
My problem is that i can't check from my main class if the secondary window is open or not.
Notice: The secondary window is being created on my maincontroller class.
Thanks!
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
primaryStage.getIcons().add(new Image("image.png"));
primaryStage.setTitle("Κάβα ποτών");
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
closing();
}
});
}
public void closing() {
//if(the secondary window is closed)
//Platform.exit();
//else
//ask confirmation with confirm alert
}
public static void main(String[] args) {
launch(args);
}
}