1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
/* * @(#)AdjustmentEvent.java 1.29 06/04/07 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package java.awt.event; import java.awt.Adjustable; import java.awt.AWTEvent; import java.awt.Event; /** * The adjustment event emitted by Adjustable objects. * @see java.awt.Adjustable * @see AdjustmentListener * * @author Amy Fowler * @version 1.29 04/07/06 * @since 1.1 */ public class AdjustmentEvent extends AWTEvent { /** * Marks the first integer id for the range of adjustment event ids. */ public static final int ADJUSTMENT_FIRST = 601; /** * Marks the last integer id for the range of adjustment event ids. */ public static final int ADJUSTMENT_LAST = 601; /** * The adjustment value changed event. */ public static final int ADJUSTMENT_VALUE_CHANGED = ADJUSTMENT_FIRST; //Event.SCROLL_LINE_UP /** * The unit increment adjustment type. */ public static final int UNIT_INCREMENT = 1; /** * The unit decrement adjustment type. */ public static final int UNIT_DECREMENT = 2; /** * The block decrement adjustment type. */ public static final int BLOCK_DECREMENT = 3; /** * The block increment adjustment type. */ public static final int BLOCK_INCREMENT = 4; /** * The absolute tracking adjustment type. */ public static final int TRACK = 5; /** * The adjustable object that fired the event. * * @serial * @see #getAdjustable */ Adjustable adjustable; /** * <code>value</code> 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 <code>adjustmentType</code> 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 <code>isAdjusting</code> 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 <code>AdjustmentEvent</code> object with the * specified <code>Adjustable</code> source, event type, * adjustment type, and value. * <p>Note that passing in an invalid <code>id</code> results in * unspecified behavior. This method throws an * <code>IllegalArgumentException</code> if <code>source</code> * is <code>null</code>. * * @param source the <code>Adjustable</code> object where the * event originated * @param id the event type * @param type the adjustment type * @param value the current value of the adjustment * @throws IllegalArgumentException if <code>source</code> is null */ public AdjustmentEvent(Adjustable source, int id, int type, int value) { this(source, id, type, value, false); } /** * Constructs an <code>AdjustmentEvent</code> object with the * specified Adjustable source, event type, adjustment type, and value. * <p>Note that passing in an invalid <code>id</code> results in * unspecified behavior. This method throws an * <code>IllegalArgumentException</code> if <code>source</code> * is <code>null</code>. * * @param source the <code>Adjustable</code> object where the * event originated * @param id the event type * @param type the adjustment type * @param value the current value of the adjustment * @param isAdjusting <code>true</code> if the event is one * of a series of multiple adjusting events, * otherwise <code>false</code> * @throws IllegalArgumentException if <code>source</code> is null * @since 1.4 */ 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 <code>Adjustable</code> object where this event originated. * * @return the <code>Adjustable</code> 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: * <ul> * <li>{@link #UNIT_INCREMENT} * <li>{@link #UNIT_DECREMENT} * <li>{@link #BLOCK_INCREMENT} * <li>{@link #BLOCK_DECREMENT} * <li>{@link #TRACK} * </ul> * @return one of the adjustment values listed above */ public int getAdjustmentType() { return adjustmentType; } /** * Returns <code>true</code> if this is one of multiple * adjustment events. * * @return <code>true</code> if this is one of multiple * adjustment events, otherwise returns <code>false</code> * @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; } }