title: How to capture a JFrame's close button click event?
body: <p>I want to call a method <code>confirmExit()</code> when the red close button of the title bar of a JFrame is clicked.</p>
  
  <p>How can I capture that event?</p>
  
  <p>I'd also like to prevent the window from closing if the user chooses not to proceed.</p>