Home | » | Java | » | Advance Java | » | Java Event Handling | » | ItemListenerTest |
---|
Item events are generated by components that present users with items to-choose from. The components that generate these events are choiceList,Checkbox, and CheckboxMenuItem. The following is the definition of the ItemEvent class.
A component can process its own item events by calling enableEvents(AWTEvent.ITEM_EVENT_MASK) and providing a processItemEvent() method. alternatively, a component can delegate item events to a listener that implements the ItemListener interface:
The applet listed below consists of a list component and a choice component. The List delegates its item events to the applet. The choice is a subclass that handles its own item events. Both events handlers print a message to the console.
The above code will be stored in the file called ItemListenerTest.java, which on compilation will crate a class file called ItemListenerTest.class. Now compile this file using below commands in the DOS mode:
C:\>jdk1.4\bin>javac ItemListenerTest.java
C:\>jdk1.4\bin>appletviewer ItemListenerTest.java
|
||
Download Complete Program |
Event Listener
Action Listener | Adjustment Listener | Mouse Listener |
Mouse Motion Listener | Window Listener | Key Listener |
Focus Listener | ITEM Listener | Text Listener |
No comments:
Post a Comment