title: Do something before window closes after user presses [x]
body: <p>I'm building an instant messenger application.I need to add an action event on the default closing button of the Swing JFrame(The little "x").<br>
  When the client presses the X button,I need to tell the server that he goes offline and only after that action occures I have to close the window.I can't seem to find how to get an action listener on the default button.</p>