Archived

This topic is now archived and is closed to further replies.

Exiting in java

This topic is 5130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If you are using java with Swing then Probably you hacve a window of some kind, if you have a class tht inherits from JFrame or have a JFrame somewhere in a class you can do:

// Aggregation
JFrame j = new JFrame();
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Inheritance
public class MyFrame extends JFrame {
public MyFrame() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
and then the window and application will die if you press the litle x in the top right corner of the window.

Otherwise if you got an window or not Zipsters advise allways works System.extit(0);

LizardCPP

Share this post


Link to post
Share on other sites