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