Listing 9 instantiates an anonymous object of an anonymous class
That anonymous object is registered as a WindowListener on the frame
Listing 9. Extending the WindowAdapter class. |
---|
//Use an anonymous class to register a window // listener on the Frame. This class extends // WindowAdapter addWindowListener(new WindowAdapter() {//begin class definition //Instance initializer {System.out.println( "Anonymous window listener class " + "name: " + getClass().getName());} public void windowClosing(WindowEvent e){ System.out.println( "Close button clicked"); System.exit(0); }//end windowClosing }//end class definition );//end addWindowListener setVisible(true); }//end constructor }//end GUI class |
File: dn.htm | [Next] | [Prev] |