wood burning stoves
The moose likes Beginning Java and the fly likes Exit an GUI application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exit an GUI application" Watch "Exit an GUI application" New topic

Exit an GUI application

Paul Steko

Joined: Jun 03, 2004
Posts: 3
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

Joined: Oct 29, 2001
Posts: 9150

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.

[How To Ask Questions On JavaRanch]
Paul Steko

Joined: Jun 03, 2004
Posts: 3
You can set what a JFrame does when you close it. To get the behavior you want, do this:


Then, when you close the JFrame, your program will end.
I agree. Here's the link: http://aspose.com/file-tools
subject: Exit an GUI application
It's not a secret anymore!