[JAVA] Close a JFrame
Solved
john93
-
Wololo -
Wololo -
Hello,
I want to close a JFrame window with a quit button.
I see how to handle the button event, but I don't know what to put to close this window.
Thank you for your help.
I want to close a JFrame window with a quit button.
I see how to handle the button event, but I don't know what to put to close this window.
Thank you for your help.
Configuration: Windows XP Firefox 2.0.0.12
3 answers
If you have instantiated an object of type JFrame and you manage it from another class, you do:
If you handle the event inside your own class (which extends JFrame), you do:
It should normally work.
--
~ Don't forget the "Resolved" tag when your problem is... resolved :) ~
monObjectJFrame.dispose();
If you handle the event inside your own class (which extends JFrame), you do:
this.dispose();
It should normally work.
--
~ Don't forget the "Resolved" tag when your problem is... resolved :) ~
john93
Thank you for your help, my program works as it should now ^^. I'm marking this topic as [resolved].
patrickjunior01
You could also do the System.exit(0) that you put in the ActionPerformed of the button.
Wololo
You're welcome!!