Is there a way to set a custom closeoperation in JavaFX. I know this one from swing and couldn't find it for JavaFX. If you close your window here by pressing the [X], it will close automatically.
You can use the onCloseRequest
property:
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override public void handle(WindowEvent t) {
System.out.println("CLOSING");
}
});
Note that if you call Platform.exit()
in your code, this won't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With