[Download]
Shows an example of how to respond the close window button (red X) in the upper-right corner of the JFrame.
Note, in addition to adding an ActionListener, you should also set the defaultCloseOperation to DO_NOTHING. (default == CLOSE_ON_EXIT).
Note, in addition to adding an ActionListener, you should also set the defaultCloseOperation to DO_NOTHING. (default == CLOSE_ON_EXIT).