Sign in to follow this  
Pac300

[java] A quick Java Question

Recommended Posts

How can i make my java application stop functioning when i hit close; Right now what is happening is an midi but when I close the program the music is still playing till i go into my process list and stop javaw.exe how can i stop this?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Is this a swing application?

Try adding something like this when you initialize it.

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

Share this post


Link to post
Share on other sites
if it's not a Swing app (i.e., an AWT app), then you need to add a WindowListener to the frame that you want to close. The WindowListener interface includes a method, windowClosing(WindowEvent), that you can capture to close your app with a call to System.exit();. Don't forget to dispose any resources before you kill the app.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this