I have a very simple JFrame window that contains one button: No.
In the main function I set setVisible(true); my JFrame and in the No button listener I want to close the window so I set the visibility to false: setVisible(false); and after that I do System.exit(0); in order to prevent possible memory leaks when running the program many times.
I have two questions:
- Do I really need to
System.exit(0);in the above case? - If I have this
JFrameas apopupwindow, I can't really useSystem.exit(0);because this will terminate the whole program. So how can I properly close the popup window and stay in the mainJFramewindow? (Now I close it only bysetVisible(false);and when I do it several times through the program execution, the program turns very slow).