Re: Exit from Exception Code
Endre Stølsvik <[email protected]>
| Newsgroups | gmane.comp.windows.devel.java.advanced |
|---|---|
| Message-ID | <[email protected]> |
Gregory A. Swarthout wrote: > Mann, Ivan H wrote: >> Well, I've said it several times and several ways, but it hasn't >> clicked. >> >> This is not running in a browser and it is not running in an applet. >> That means any statement about an applet or a browser has no relation to >> the problem. The code is destined to run in an applet someday, but what >> I asked about has no relation at all to the workings of an applet. >> >> Again: I have a class with a main method which I execute from the >> command line in Unix. That program does several things, including >> popping up a gui which has several buttons. Usually the Exit button >> causes the gui to disappear and causes the prompt to appear on the >> command line. There are events and circumstances which can cause a >> method to create a JOptionPane dialog to tell the user something. When >> the JOptionPane appears, I respond to the dialog, it goes away, and >> everything works normally from then on, except that clicking the Exit >> button causes the gui to go away but does not cause the prompt to appear >> and the shell won't accept commands until I type Ctrl-C. > > Then I repeat my initial response that you need to do a System.exit(0); > call to exit from the EventDispatchThread Just so this won't be standing as a truth: No, you don't. If your AWT/Swing program doesn't exit when you close your windows and whatnots, then you've coded shit, and you should find the non-released resource. Usually some window that isn't disposed, just hidden. You'll probably leak memory over time unless you actually manage to make the JVM exit when the "last window goes". So that exit(0) advice is very bad, IMO. Kind regards, Endre. =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com