001: /*
002: * @(#)AdjustmentEvent.java 1.21 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package java.awt.event;
029:
030: import java.awt.Adjustable;
031: import java.awt.AWTEvent;
032:
033: /**
034: * The adjustment event emitted by Adjustable objects.
035: * @see java.awt.Adjustable
036: * @see AdjustmentListener
037: *
038: * @version 1.17 08/19/02
039: * @author Amy Fowler
040: */
041: public class AdjustmentEvent extends AWTEvent {
042: /**
043: * Marks the first integer id for the range of adjustment event ids.
044: */
045: public static final int ADJUSTMENT_FIRST = 601;
046: /**
047: * Marks the last integer id for the range of adjustment event ids.
048: */
049: public static final int ADJUSTMENT_LAST = 601;
050: /**
051: * The adjustment value changed event.
052: */
053: public static final int ADJUSTMENT_VALUE_CHANGED = ADJUSTMENT_FIRST; //Event.SCROLL_LINE_UP
054: /**
055: * The unit increment adjustment type.
056: */
057: public static final int UNIT_INCREMENT = 1;
058: /**
059: * The unit decrement adjustment type.
060: */
061: public static final int UNIT_DECREMENT = 2;
062: /**
063: * The block decrement adjustment type.
064: */
065: public static final int BLOCK_DECREMENT = 3;
066: /**
067: * The block increment adjustment type.
068: */
069: public static final int BLOCK_INCREMENT = 4;
070: /**
071: * The absolute tracking adjustment type.
072: */
073: public static final int TRACK = 5;
074: Adjustable adjustable;
075: int value;
076: int adjustmentType;
077: /*
078: * JDK 1.1 serialVersionUID
079: */
080: private static final long serialVersionUID = 5700290645205279921L;
081:
082: /**
083: * Constructs a AdjustmentEvent object with the specified Adjustable source,
084: * type, and value.
085: * @param source the Adjustable object where the event originated
086: * @id the event type
087: * @type the adjustment type
088: * @value the current value of the adjustment
089: */
090: public AdjustmentEvent(Adjustable source, int id, int type,
091: int value) {
092: super (source, id);
093: adjustable = source;
094: this .adjustmentType = type;
095: this .value = value;
096: }
097:
098: /**
099: * Returns the Adjustable object where this event originated.
100: */
101: public Adjustable getAdjustable() {
102: return adjustable;
103: }
104:
105: /**
106: * Returns the current value in the adjustment event.
107: */
108: public int getValue() {
109: return value;
110: }
111:
112: /**
113: * Returns the type of adjustment which caused the value changed
114: * event.
115: * @see UNIT_INCREMENT
116: * @see UNIT_DECREMENT
117: * @see BLOCK_INCREMENT
118: * @see BLOCK_DECREMENT
119: * @see TRACK
120: */
121: public int getAdjustmentType() {
122: return adjustmentType;
123: }
124:
125: public String paramString() {
126: String typeStr;
127: switch (id) {
128: case ADJUSTMENT_VALUE_CHANGED:
129: typeStr = "ADJUSTMENT_VALUE_CHANGED";
130: break;
131:
132: default:
133: typeStr = "unknown type";
134: }
135: String adjTypeStr;
136: switch (adjustmentType) {
137: case UNIT_INCREMENT:
138: adjTypeStr = "UNIT_INCREMENT";
139: break;
140:
141: case UNIT_DECREMENT:
142: adjTypeStr = "UNIT_DECREMENT";
143: break;
144:
145: case BLOCK_INCREMENT:
146: adjTypeStr = "BLOCK_INCREMENT";
147: break;
148:
149: case BLOCK_DECREMENT:
150: adjTypeStr = "BLOCK_DECREMENT";
151: break;
152:
153: case TRACK:
154: adjTypeStr = "TRACK";
155: break;
156:
157: default:
158: adjTypeStr = "unknown type";
159: }
160: return typeStr + ",adjType=" + adjTypeStr + ",value=" + value;
161: }
162: }
|