Home | » | Java | » | Advance Java | » | Java Event Handling | » | AdjustmentListener |
---|
Adjustment listener is responsible for handling all the events that are generated where and end user moves the scrollbar. The various integer constants used by the adjustment listener method are:
- BLOCK_DECREMENT
- BLOCK_INCREMENT
- TRACK
- UNIT_DECREMENT
- UNIT_INCREMENT
- ADJUSTMENT_VALUE_CHANGED
Adjustment events are sent by scrollbars.
The applet code listed below constructs two scrollbars. The first is an ordinary scrollbar that delegates adjustment events to the applet. When the scrollbar moves, the applet writes a message to the console.
The second scrollbar is a subclass called SelfScrollbar. This subclass handles its own adjustment events. When the SelfScrollbar moves, the scrollbar itself writes a message to the console.
The above code will be stored in the file called AdjustmentListenerTest.java, which on compilation will crate a class file called AdjustmentListenerTest.class. Now compile this file using below commands in the DOS mode:
C:\>jdk1.4\bin>javac AdjustmentListenerTest.java
C:\>jdk1.4\bin>appletviewer AdjustmentListenerTest.java
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