<<< SwingMain.java | Index | SwingMain.java >>> |
The system exit procedure is not called automatically when a user clicks on the close box X.
To enable expected behavior,
Add a WindowListener to the frame.
Catch the WindowClosing event.
This can be done most effectively by subclassing the WindowAdapter class as follows:
JFrame frame = new JFrame("JFrame is me"); frame.addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent ev) { System.exit(0); } } );
See next side for complete example.
<<< SwingMain.java | Index | SwingMain.java >>> |