/* * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package java.awt.event; import java.awt.Adjustable; import java.awt.AWTEvent; /** * The adjustment event emitted by Adjustable objects like * {@link java.awt.Scrollbar} and {@link java.awt.ScrollPane}. * When the user changes the value of the scrolling component, * it receives an instance of {@code AdjustmentEvent}. *
* An unspecified behavior will be caused if the {@code id} parameter * of any particular {@code AdjustmentEvent} instance is not * in the range from {@code ADJUSTMENT_FIRST} to {@code ADJUSTMENT_LAST}. *
* The {@code type} of any {@code AdjustmentEvent} instance takes one of the following * values: *
value
will contain the new value of the
* adjustable object. This value will always be in a
* range associated adjustable object.
*
* @serial
* @see #getValue
*/
int value;
/**
* The adjustmentType
describes how the adjustable
* object value has changed.
* This value can be increased/decreased by a block or unit amount
* where the block is associated with page increments/decrements,
* and a unit is associated with line increments/decrements.
*
* @serial
* @see #getAdjustmentType
*/
int adjustmentType;
/**
* The isAdjusting
is true if the event is one
* of the series of multiple adjustment events.
*
* @since 1.4
* @serial
* @see #getValueIsAdjusting
*/
boolean isAdjusting;
/*
* JDK 1.1 serialVersionUID
*/
private static final long serialVersionUID = 5700290645205279921L;
/**
* Constructs an AdjustmentEvent
object with the
* specified Adjustable
source, event type,
* adjustment type, and value.
* This method throws an
* IllegalArgumentException
if source
* is null
.
*
* @param source The Adjustable
object where the
* event originated
* @param id An integer indicating the type of event.
* For information on allowable values, see
* the class description for {@link AdjustmentEvent}
* @param type An integer indicating the adjustment type.
* For information on allowable values, see
* the class description for {@link AdjustmentEvent}
* @param value The current value of the adjustment
* @throws IllegalArgumentException if source
is null
* @see #getSource()
* @see #getID()
* @see #getAdjustmentType()
* @see #getValue()
*/
public AdjustmentEvent(Adjustable source, int id, int type, int value) {
this(source, id, type, value, false);
}
/**
* Constructs an AdjustmentEvent
object with the
* specified Adjustable source, event type, adjustment type, and value.
*
This method throws an
* IllegalArgumentException
if source
* is null
.
*
* @param source The Adjustable
object where the
* event originated
* @param id An integer indicating the type of event.
* For information on allowable values, see
* the class description for {@link AdjustmentEvent}
* @param type An integer indicating the adjustment type.
* For information on allowable values, see
* the class description for {@link AdjustmentEvent}
* @param value The current value of the adjustment
* @param isAdjusting A boolean that equals true
if the event is one
* of a series of multiple adjusting events,
* otherwise false
* @throws IllegalArgumentException if source
is null
* @since 1.4
* @see #getSource()
* @see #getID()
* @see #getAdjustmentType()
* @see #getValue()
* @see #getValueIsAdjusting()
*/
public AdjustmentEvent(Adjustable source, int id, int type, int value, boolean isAdjusting) {
super(source, id);
adjustable = source;
this.adjustmentType = type;
this.value = value;
this.isAdjusting = isAdjusting;
}
/**
* Returns the Adjustable
object where this event originated.
*
* @return the Adjustable
object where this event originated
*/
public Adjustable getAdjustable() {
return adjustable;
}
/**
* Returns the current value in the adjustment event.
*
* @return the current value in the adjustment event
*/
public int getValue() {
return value;
}
/**
* Returns the type of adjustment which caused the value changed
* event. It will have one of the following values:
*
true
if this is one of multiple
* adjustment events.
*
* @return true
if this is one of multiple
* adjustment events, otherwise returns false
* @since 1.4
*/
public boolean getValueIsAdjusting() {
return isAdjusting;
}
public String paramString() {
String typeStr;
switch(id) {
case ADJUSTMENT_VALUE_CHANGED:
typeStr = "ADJUSTMENT_VALUE_CHANGED";
break;
default:
typeStr = "unknown type";
}
String adjTypeStr;
switch(adjustmentType) {
case UNIT_INCREMENT:
adjTypeStr = "UNIT_INCREMENT";
break;
case UNIT_DECREMENT:
adjTypeStr = "UNIT_DECREMENT";
break;
case BLOCK_INCREMENT:
adjTypeStr = "BLOCK_INCREMENT";
break;
case BLOCK_DECREMENT:
adjTypeStr = "BLOCK_DECREMENT";
break;
case TRACK:
adjTypeStr = "TRACK";
break;
default:
adjTypeStr = "unknown type";
}
return typeStr
+ ",adjType="+adjTypeStr
+ ",value="+value
+ ",isAdjusting="+isAdjusting;
}
}