I'm making a application in JavaFX 2.0. From my main window I am starting a new window with some settings. After I am done adjusting the settings I want to press a button like "Save changes".
I would like this button to save the changes and close the window. By closing i mean killing it, not placing it in the background or setting the visibility. I've read about a method Stage.close()
As you can see it's similar to the method Hide(), which only hides the window, not closing it.
Q: Anybody knows any methods or have some code that would help me close a window?
All help will be greatly appreciated. Thanks!
The documentation you linked states that
Closes this Stage. This call is equivalent to hide().
hide() is equivalent to
close() closes the stage, then
hide() also closes the stage.
When all stages in an application are hidden (or closed if you like, because it is the same thing), the application exits. Confusing, I know, but that's just the way the JavaFX team decided to name and implement the actions.
If desired, the Platform.setImplicitExit(boolean) method can be used to switch off the default behaviour of exiting the application when the last window is closed or hidden.
This worked perfectly for me (with the import for