*
The moose likes Swing / AWT / SWT and the fly likes Getting the applet to die on exit... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Getting the applet to die on exit..." Watch "Getting the applet to die on exit..." New topic
Author

Getting the applet to die on exit...

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
If you exit my applet the sounds continue to play. Does anyone know how I can truly exit the applet when a user hits the X?
Example: http://www.isy.vcu.edu/~cstewart/info350/FinalProject.html
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

You'll need add a WindowListener to the frame that you pop up from the applet. In the WindowListener's windowClosing() method you will stop whatever thread is playing the sound.
[ July 03, 2003: Message edited by: Nathan Pruett ]

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
The sound thread is in a different class than the Applet (and JFrame class). Do you know how I can do this?
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

How does the sound thread get started, then? You'll need to modify that class to be able to kill the thread when you need to.
Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
The thread itself was being created in a Sounds class. So I just moved the creation into my Layout class. That action works great. Thanks for your help!
Here is what I'm working on in case you are interested (beware, the cards don't move yet )
http://www.isy.vcu.edu/~cstewart/info350/FinalProject.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting the applet to die on exit...