Reputation: 7699
I need to creat an app that shows the primary stage to the user, and if the user closes the stage, instead of finishing the application, it should just hide the stage for later use. On swing we could just call setVisible(false) to a JFrame or JDialog, but how to do it on JavaFX?
Upvotes: 9
Views: 10239
Reputation: 209225
Once the JavaFX toolkit has started, by default it will close down when the last visible window is closed.
To prevent this, you can call
Platform.setImplicitExit(false);
You typically do this in your start(...)
method, though it can be called from any thread.
To exit the application, you would then need to call
Platform.exit();
(as the application no longer exits automatically).
Upvotes: 30