I've written this simple first hello world program:
The program shows a window with the hello world, but when I close the window, the program's still alive. I supose I have to trap somehow the close window event and then exit the app somehow. Can anybody kindly point me in the right direction?
Also, I really don't see in wich point the event pool is set, and if there's a main window or something. I'm following tutorials and that's what I've managed to come with as a first Swing example, so if anyone can give a brief explanation, it'll be much appreciated.
You can trap the close window event - look at the addWindowListener() method inJFrame. But there's an easier way that will do what you want here:
Joined: Aug 12, 2011
Thanks, that was useful. Just out of curiosity, if I set the window to DISPOSE_ON_CLOSE, the window is disposed as expected, and then the program ends equally. Am I right to assume that the internal event pool stops execution when there are no windows or objects alive? If that's true, what's the default status for a window, something like "HIDE_ON_CLOSE"?