GUI Changes: The AWT Grows Up |
Adjustment events notify you of changes in the value of components that implement theAdjustable
interface.Adjustable
objects have an integer value, and they generate adjustment events whenever that value changes.In addition to the
Scrollbar
class,, which directly implementsAdjustable
, theScrollPane
class's vertical and horizontal scrollbars implementAdjustable
. If you want to peek at adjustment events within a scroll pane, you can get the necessaryAdjustable
objects using thegetVAdjustable
andgetHAdjustable
methods.There are five kinds of adjustment events: [CHECK ALL THESE]
- track
- The user explicitly adjusted the value of the component. For a scrollbar, this might be the result of the user dragging the scrollbar knob.
- unit increment
unit decrement- The user indicated the wish to slightly adjust the value of the component. For a scrollbar, this might be the result of the user clicking once on an up arrow or down arrow.
- block increment
block decrement- The user indicated the wish to adjust the value of the component by a larger amount. For scrollbar, this might be the result of the user clicking once just above the down arrow or just below the up arrow.
Adjustment Event Methods
TheAdjustmentListener
interface has just one method, so it has no corresponding adapter class. Here's the method:
void adjustmentValueChanged(AdjustmentEvent)
- Called by the AWT just after the listened-to component's value changes.
Examples of Handling Adjustment Events
The following applet demonstrates item events. [describe applet][applet goes here]
Try this:
- Do something.
You can find the applet's code [nowhere yet]. Here is the applet's item event handling code:
[code goes here]You can find more examples of item listeners in the following sections: [LIST GOES HERE]
The
AdjustmentEvent
ClassEach item event method has a single parameter: anAdjustmentEvent
object. TheAdjustmentEvent
class defines the following handy methods:
Adjustable getAdjustable()
- Returns the component the generated the event.
int getAdjustmentType()
- Returns the type of adjustment that occurred. The returned value is one of the following constants defined in the
AdjustmentEvent
class:UNIT_INCREMENT
,UNIT_DECREMENT
,BLOCK_INCREMENT
,BLOCK_DECREMENT
,TRACK
.int getValue()
- Returns the value of the component just after the adjustment occurred.
GUI Changes: The AWT Grows Up |