47 |
import javax.swing.event.EventListenerList; |
import javax.swing.event.EventListenerList; |
48 |
|
|
49 |
/** |
/** |
50 |
* A default implementation of BoundedRangeModel. |
* A default implementation of <code>BoundedRangeModel</code>. |
51 |
* |
* |
52 |
* @author <a href="mailto:aselkirk@sympatico.ca">Andrew Selkirk</a> |
* @author <a href="mailto:aselkirk@sympatico.ca">Andrew Selkirk</a> |
53 |
* @author <a href="mailto:brawer@dandelis.ch">Sascha Brawer</a> |
* @author <a href="mailto:brawer@dandelis.ch">Sascha Brawer</a> |
59 |
* The identifier of this class in object serialization. Verified |
* The identifier of this class in object serialization. Verified |
60 |
* using the serialver tool of Sun J2SE 1.4.1_01. |
* using the serialver tool of Sun J2SE 1.4.1_01. |
61 |
*/ |
*/ |
62 |
static final long serialVersionUID = 5034068491295259790L; |
private static final long serialVersionUID = 5034068491295259790L; |
63 |
|
|
64 |
|
|
65 |
/** |
/** |
67 |
* when the state of this range model has changed. |
* when the state of this range model has changed. |
68 |
* |
* |
69 |
* <p>The event object is created on demand, the first time it |
* <p>The event object is created on demand, the first time it |
70 |
* is actually needed. |
* is actually needed.</p> |
71 |
* |
* |
72 |
* @see #fireStateChanged() |
* @see #fireStateChanged() |
73 |
*/ |
*/ |
155 |
* @param maximum the initial maximal value of the range model. |
* @param maximum the initial maximal value of the range model. |
156 |
* |
* |
157 |
* @throws IllegalArgumentException if the following condition is |
* @throws IllegalArgumentException if the following condition is |
158 |
* not satisfied: <code>minimum <= value <= value + extent <= |
* not satisfied: <code>minimum <= value <= value + extent <= |
159 |
* maximum</code>. |
* maximum</code>. |
160 |
*/ |
*/ |
161 |
public DefaultBoundedRangeModel(int value, int extent, int minimum, |
public DefaultBoundedRangeModel(int value, int extent, int minimum, |
176 |
/** |
/** |
177 |
* Returns a string with all relevant properties of this range |
* Returns a string with all relevant properties of this range |
178 |
* model. |
* model. |
179 |
|
* |
180 |
|
* @return a string representing the object |
181 |
*/ |
*/ |
182 |
public String toString() |
public String toString() |
183 |
{ |
{ |
195 |
* Returns the current value of this bounded range model. In a |
* Returns the current value of this bounded range model. In a |
196 |
* scroll bar visualization of a {@link BoundedRangeModel}, the |
* scroll bar visualization of a {@link BoundedRangeModel}, the |
197 |
* <code>value</code> is displayed as the position of the thumb. |
* <code>value</code> is displayed as the position of the thumb. |
198 |
|
* |
199 |
|
* @return the value |
200 |
*/ |
*/ |
201 |
public int getValue() |
public int getValue() |
202 |
{ |
{ |
210 |
* <code>value</code> is displayed as the position of the thumb; |
* <code>value</code> is displayed as the position of the thumb; |
211 |
* changing the <code>value</code> of a scroll bar's model |
* changing the <code>value</code> of a scroll bar's model |
212 |
* thus moves the thumb to a different position. |
* thus moves the thumb to a different position. |
213 |
|
* |
214 |
|
* @param value the value |
215 |
*/ |
*/ |
216 |
public void setValue(int value) |
public void setValue(int value) |
217 |
{ |
{ |
232 |
* a number greater than or equal to zero. In a scroll bar |
* a number greater than or equal to zero. In a scroll bar |
233 |
* visualization of a {@link BoundedRangeModel}, the |
* visualization of a {@link BoundedRangeModel}, the |
234 |
* <code>extent</code> is displayed as the size of the thumb. |
* <code>extent</code> is displayed as the size of the thumb. |
235 |
|
* |
236 |
|
* @return the extent |
237 |
*/ |
*/ |
238 |
public int getExtent() |
public int getExtent() |
239 |
{ |
{ |
290 |
|
|
291 |
/** |
/** |
292 |
* Returns the current maximal value of this bounded range model. |
* Returns the current maximal value of this bounded range model. |
293 |
|
* |
294 |
|
* @return the maximum |
295 |
*/ |
*/ |
296 |
public int getMaximum() |
public int getMaximum() |
297 |
{ |
{ |
323 |
* around; when the mouse is relased, they set the property to |
* around; when the mouse is relased, they set the property to |
324 |
* <code>false</code> and post a final {@link ChangeEvent}. |
* <code>false</code> and post a final {@link ChangeEvent}. |
325 |
* |
* |
326 |
* @returns <code>true</code> if the value will change soon again; |
* @return <code>true</code> if the value will change soon again; |
327 |
* <code>false</code> if the value will probably not change soon. |
* <code>false</code> if the value will probably not change soon. |
328 |
*/ |
*/ |
329 |
public boolean getValueIsAdjusting() |
public boolean getValueIsAdjusting() |
354 |
|
|
355 |
|
|
356 |
/** |
/** |
357 |
* setRangeProperties |
* Sets all properties. |
358 |
* |
* |
359 |
* @param value the new value of the range model. In a scroll bar |
* @param value the new value of the range model. In a scroll bar |
360 |
* visualization of a {@link BoundedRangeModel}, the |
* visualization of a {@link BoundedRangeModel}, the |
432 |
*/ |
*/ |
433 |
protected void fireStateChanged() |
protected void fireStateChanged() |
434 |
{ |
{ |
435 |
Object[] listeners; |
ChangeListener[] listeners = getChangeListeners(); |
436 |
|
|
437 |
|
if (changeEvent == null) |
438 |
|
changeEvent = new ChangeEvent(this); |
439 |
|
|
440 |
listeners = listenerList.getListenerList(); |
for (int i = listeners.length - 1; i >= 0; --i) |
441 |
for (int i = listeners.length - 2; i >= 0; i -= 2) |
listeners[i].stateChanged(changeEvent); |
|
if (listeners[i] == ChangeListener.class) |
|
|
{ |
|
|
if (changeEvent == null) |
|
|
changeEvent = new ChangeEvent(this); |
|
|
((ChangeListener) listeners[i + 1]).stateChanged(changeEvent); |
|
|
} |
|
442 |
} |
} |
443 |
|
|
444 |
|
|