File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exit an GUI application

 
Paul Steko
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a GUI application which displays three different messages for a period of 5 seconds in the same JTextArea. When I close the window before de second or third message is displayed the thread is still being executed in the �DOS Window�. Is it possible to stop the tread (and the entire program) when de GUI is closed?

I use the following code:

 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aan de Stegge Maarten:



Well, there isn't a listener for the window closing event until after your ExitTest constructor runs it's course, so I'd say no.
 
Paul Steko
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can set what a JFrame does when you close it. To get the behavior you want, do this:

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Then, when you close the JFrame, your program will end.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic