1: import java.awt.event.WindowAdapter; 2: import java.awt.event.WindowEvent; 3: 4: /** 5: If you register an object of this class as a listener to any 6: object of the class JFrame, the object will end the program 7: and close the JFrame, if the user clicks the JFrame's 8: close-window button. 9: */ 10: public class WindowDestroyer extends WindowAdapter 11: { 12: public void windowClosing(WindowEvent e) 13: { 14: System.exit(0); 15: } 16: }