title: Java - how to DO_NOTHING_ON_CLOSE, then enable EXIT_ON_CLOSE?
body: <p>I've got a game where I'm trying to intercept a close event and return the user to the main menu instead.  I've got half of it figured out using <code>DO_NOTHING_ON_CLOSE</code> but then the problem is I can't return the regular functionality to the menu screen.</p>
  
  <p>As you probably know, the problem is, the <code>windowClosing</code> method is apparently the last listener fired if <code>DO_NOTHING...</code> is the operation.  </p>
  
  <p>So, my question is, how can I return the <code>EXIT_ON_CLOSE</code> to the window, <em>after</em> <code>NOTHING</code> has been done?  I'd like to do it without any user input in the meantime. I can switch to another JFrame and handle it from there, but there's got to be a better way to do it.</p>
  
  <p>Code sample:</p>
  
  <pre><code>WindowAdapter waReturnToMenu = new WindowAdapter() {
     @Override
     public void windowClosing(final WindowEvent e) {
          view.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
          changeMenuState(0);
     }
  };
  </code></pre>
  
  <p>Then, in change menu state:</p>
  
  <pre><code>public void changeMenuState(int i0) {
      //...screen returns to menu, then
  
      view.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  }
  </code></pre>