title: Java Swing adding Action Listener for EXIT_ON_CLOSE
body: <p>I have a simple GUI:</p>
  
  <pre><code>    public class MyGUI extends JFrame{
  
          public MyGUI(){
             run();
          }
  
          void run(){
             setSize(100, 100);
             setVisible(true);
             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// maybe an action listener here
          }
      }
  </code></pre>
  
  <p>I would like to print out this message:</p>
  
  <pre><code> System.out.println("Closed");
  </code></pre>
  
  <p>When the GUI is closed (when the X is pressed). How can I do that?</p>