title: e.getWindow().dispose() is not working?
body: <p>I have a main program which calls a <code>JFrame</code> to get User information, If a user press submit I am storing the information in POJO and getting it into Main program.</p>
  
  <p>If User clicks on Exit, I want to dispose the <code>JFrame</code> and want to exit the main program as well after executing one logging statement in main method.</p>
  
  <p>If I use - </p>
  
  <pre><code> this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  and
  this.addWindowListener(new WindowAdapter() {
              public void windowClosed(WindowEvent e) {
                  e.getWindow().dispose();
              }
          });
  </code></pre>
  
  <p>all the Threads exit immediately and I am not able to execute logging statments in main method.</p>
  
  <p>If I use-</p>
  
  <pre><code>this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   this.addWindowListener(new WindowAdapter() {
              public void windowClosed(WindowEvent e) {
                  e.getWindow().dispose();
              }
          });
  </code></pre>
  
  <p>My main method execute those logging statments but it never exit, It stay silent after executing all the statements.</p>
  
  <p>If I use this - </p>
  
  <pre><code>this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   this.addWindowListener(new WindowAdapter() {
              public void windowClosed(WindowEvent e) {
                  Thread.currentThread.interrupt();
              }
          });
  </code></pre>
  
  <p>Everything works fine. But is it the correct way of doing this?</p>