File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 8708
    
    6

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[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
 
Similar Threads
Daemon Thread
Help debugging and running My GUI TCP Chatroom!
Leave a small pause when printing lines
Help with Head First Java simplechatclient -- NullPointerException
ExecutorService shutdown - blocking?