When exiting a JavaFX program I'm overriding Application.stop() in order to check for unsaved changes. This works okay, but it would be nice to give the user the option to cancel the operation.
相关问题
- How to properly use Weld in JavaFX 2 application?
- JavaFX, MediaPlayer - volume trouble! Why the volu
- Is there an event or something i can use when a sh
- JavaFX 2 ComboBox setValue() does not set CB text
- How to enable HTML5 local storage in javafx WebVie
相关文章
- window端口父进程PID查询
- Can you get the parent GTK window from a widget?
- How can I position the window's position on st
- How to change the color of pane in javafx?
- TableView has more columns than specified
- How to merge cells in JavaFX Scene builder?
- How to get the user login/logoff time by Python fo
- JavaFX: Tested/confirmed hardware (GPU) accelerati
Application.stop() is last-chance-saloon in other words although it does trap the exit, it's a bit late to revoke the exit process.
Better is to set a listener for the close request which can be cancelled by consuming the event.
In the application class:
and then in the application controller, referenced as
appCtrl
above:noting: mainAppPane is referenced in the FXML ( using the JavaFX Scene Builder in this case ) to allow access to the scene and window; the dialog is one extended from https://github.com/4ntoine/JavaFxDialog and fileSave is the event handler for File -> Save menu item. For the File -> Exit menu item:
Hope this helps someone!