[JAVA] Close a JFrame

Solved
john93 -  
 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.
Configuration: Windows XP Firefox 2.0.0.12

3 answers

  1. kij_82 Posted messages 4102 Registration date   Status Contributor Last intervention   857
     
    If you have instantiated an object of type JFrame and you manage it from another class, you do:
     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 :) ~
    41
    1. john93
       
      Thank you for your help, my program works as it should now ^^. I'm marking this topic as [resolved].
      0
    2. patrickjunior01
       
      You could also do the System.exit(0) that you put in the ActionPerformed of the button.
      0
    3. Wololo
       
      You're welcome!!
      0