aspose file tools*
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
Author

Exit an GUI application

Maarten aan de Stegge
Greenhorn

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
Bartender

Joined: Oct 29, 2001
Posts: 8971
    
    9

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]
Maarten aan de Stegge
Greenhorn

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:

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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