Search code examples
javaswingdispose

Java: System.exit() parameters


I am having a simple question, but somewhat questionable. This is the situation.

In my application, you can open new windows by clicking the new button. When you click the "X" (close) button, it will first ask whether you want to save your work. If no, it will use system.exit(0) to exit. The case is, this closes all the open "new" windows. I want to close only the window which user selected the option "no save". How can I do this? Please help!


Solution

  • It is a text editor, like notepad. Uses "new" to open new "windows"."

    Alternatives (all mentioned in or linked from this answer to The Use of Multiple JFrames, Good/Bad Practice?):

    1. JTabbedPane
    2. JDesktopPane containing JInternalFrame instances
    3. CardLayout
    4. (see linked answer..)