Merge from the pain train
[official-gcc.git] / libjava / java / awt / event / AdjustmentEvent.java
blobf7c7ae48e7cdd711bc9fc5435576e32f8a75f36e
1 /* AdjustmentEvent.java -- an adjustable value was changed
2 Copyright (C) 1999, 2002, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.awt.event;
41 import java.awt.AWTEvent;
42 import java.awt.Adjustable;
44 /**
45 * This class represents an event that is generated when an adjustable
46 * value is changed.
48 * @author Aaron M. Renn (arenn@urbanophile.com)
49 * @see Adjustable
50 * @see AdjustmentListener
51 * @since 1.1
52 * @status updated to 1.4
54 public class AdjustmentEvent extends AWTEvent
56 /**
57 * Compatible with JDK 1.1+.
59 private static final long serialVersionUID = 5700290645205279921L;
61 /** This is the first id in the range of ids used by adjustment events. */
62 public static final int ADJUSTMENT_FIRST = 601;
64 /** This is the last id in the range of ids used by adjustment events. */
65 public static final int ADJUSTMENT_LAST = 601;
67 /** This is the id indicating an adjustment value changed. */
68 public static final int ADJUSTMENT_VALUE_CHANGED = 601;
70 /** Adjustment type for unit increments. */
71 public static final int UNIT_INCREMENT = 1;
73 /** Adjustment type for unit decrements. */
74 public static final int UNIT_DECREMENT = 2;
76 /** Adjustment type for block decrements. */
77 public static final int BLOCK_DECREMENT = 3;
79 /** Adjustment type for block increments. */
80 public static final int BLOCK_INCREMENT = 4;
82 /** Adjustment type for tracking adjustments. */
83 public static final int TRACK = 5;
85 /**
86 * The adjustable object that caused the event.
88 * @see #getAdjustable()
89 * @serial the cause
91 private final Adjustable adjustable;
93 /**
94 * The type of adjustment, one of {@link #UNIT_INCREMENT},
95 * {@link #UNIT_DECREMENT}, {@link #BLOCK_INCREMENT},
96 * {@link #BLOCK_DECREMENT}, or {@link #TRACK}.
98 * @see #getAdjustmentType()
99 * @serial the adjustment type
101 private final int adjustmentType;
104 * The new value of the adjustable; it should be in the range of the
105 * adjustable cause.
107 * @see #getValue()
108 * @serial the adjustment value
110 private final int value;
113 * True if this is in a series of multiple adjustment events.
115 * @see #getValueIsAdjusting()
116 * @serial true if this is not the last adjustment
117 * @since 1.4
119 private final boolean isAdjusting;
122 * Initializes an instance of <code>AdjustmentEvent</code> with the
123 * specified source, id, type, and value. Note that an invalid id leads to
124 * unspecified results.
126 * @param source the source of the event
127 * @param id the event id
128 * @param type the event type, one of the constants of this class
129 * @param value the value of the adjustment
130 * @throws IllegalArgumentException if source is null
132 public AdjustmentEvent(Adjustable source, int id, int type, int value)
134 this(source, id, type, value, false);
138 * Initializes an instance of <code>AdjustmentEvent</code> with the
139 * specified source, id, type, and value. Note that an invalid id leads to
140 * unspecified results.
142 * @param source the source of the event
143 * @param id the event id
144 * @param type the event type, one of the constants of this class
145 * @param value the value of the adjustment
146 * @param isAdjusting if this event is in a chain of adjustments
147 * @throws IllegalArgumentException if source is null
148 * @since 1.4
150 public AdjustmentEvent(Adjustable source, int id, int type, int value,
151 boolean isAdjusting)
153 super(source, id);
154 this.adjustmentType = type;
155 this.value = value;
156 adjustable = source;
157 this.isAdjusting = isAdjusting;
161 * This method returns the source of the event as an <code>Adjustable</code>.
163 * @return the <code>Adjustable</code> source of the event
165 public Adjustable getAdjustable()
167 return adjustable;
171 * Returns the new value of the adjustable object.
173 * @return the value of the event
175 public int getValue()
177 return value;
181 * Returns the type of the event, which will be one of
182 * {@link #UNIT_INCREMENT}, {@link #UNIT_DECREMENT},
183 * {@link #BLOCK_INCREMENT}, {@link #BLOCK_DECREMENT}, or {@link #TRACK}.
185 * @return the type of the event
187 public int getAdjustmentType()
189 return adjustmentType;
193 * Test if this event is part of a sequence of multiple adjustements.
195 * @return true if this is not the last adjustment
196 * @since 1.4
198 public boolean getValueIsAdjusting()
200 return isAdjusting;
204 * Returns a string that describes the event. This is in the format
205 * <code>"ADJUSTMENT_VALUE_CHANGED,adjType=" + &lt;type&gt; + ",value="
206 * + getValue() + ",isAdjusting=" + getValueIsAdjusting()</code>, where
207 * type is the name of the constant returned by getAdjustmentType().
209 * @return a string that describes the event
211 public String paramString()
213 return (id == ADJUSTMENT_VALUE_CHANGED
214 ? "ADJUSTMENT_VALUE_CHANGED,adjType=" : "unknown type,adjType=")
215 + (adjustmentType == UNIT_INCREMENT ? "UNIT_INCREMENT,value="
216 : adjustmentType == UNIT_DECREMENT ? "UNIT_DECREMENT,value="
217 : adjustmentType == BLOCK_INCREMENT ? "BLOCK_INCREMENT,value="
218 : adjustmentType == BLOCK_DECREMENT ? "BLOCK_DECREMENT,value="
219 : adjustmentType == TRACK ? "TRACK,value=" : "unknown type,value=")
220 + value + ",isAdjusting=" + isAdjusting;
222 } // class AdjustmentEvent