Listing 5 begins an anonymous inner class
Listing 5. An anonymous inner class for low-level event handling. |
---|
//This code defines an anonymous Inner Class // w/mouse events enabled. The new class // extends Button. This class uses low-level // event handling to handle mouse clicked // events on the button. This is an // anonymous alternative to the local class // defined above. add(new Button("B") {//Begin class definition {//Instance initializer enableEvents( AWTEvent.MOUSE_EVENT_MASK); System.out.println( "Anonymous class B name: " + getClass().getName()); }//end instance initializer |
File: ck.htm | [Next] | [Prev] |