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?
1 Answer
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).
3 Comments
ZenOokami
Sorry if this is a bit dated, but out curiosity, would you happen to know how to show a program that has been hidden?
homerun
Can we implement system tray alongside those actions?
show()on it at a later time to display it again.