javax.swing

Class DefaultBoundedRangeModel

Implemented Interfaces:
BoundedRangeModel, Serializable

public class DefaultBoundedRangeModel
extends Object
implements BoundedRangeModel, Serializable

The default implementation of BoundedRangeModel.
See Also:
Serialized Form

Field Summary

protected ChangeEvent
changeEvent
An event that is sent to all registered ChangeListeners when the state of this range model has changed.
protected EventListenerList
listenerList
The list of the currently registered EventListeners.

Constructor Summary

DefaultBoundedRangeModel()
Constructs a DefaultBoundedRangeModel with default values for the properties.
DefaultBoundedRangeModel(int value, int extent, int minimum, int maximum)
Constructs a DefaultBoundedRangeModel with the specified values for some properties.

Method Summary

void
addChangeListener(ChangeListener listener)
Subscribes a ChangeListener to state changes.
extends EventListener> T[] getListeners(Class listenerType)
Retrieves the current listeners of the specified class.
protected void
fireStateChanged()
Sends a ChangeEvent to any registered ChangeListeners.
ChangeListener[]
getChangeListeners()
Returns all ChangeListeners that are currently subscribed for changes to this DefaultBoundedRangeModel.
int
getExtent()
Returns the current extent of this bounded range model, which is a number greater than or equal to zero.
int
getMaximum()
Returns the current maximal value of this bounded range model.
int
getMinimum()
Returns the current minimal value of this bounded range model.
int
getValue()
Returns the current value of this bounded range model.
boolean
getValueIsAdjusting()
Returns whether or not the value of this bounded range model is going to change in the immediate future.
void
removeChangeListener(ChangeListener listener)
Cancels the subscription of a ChangeListener.
void
setExtent(int extent)
Changes the current extent of this bounded range model.
void
setMaximum(int maximum)
Changes the current maximal value of this bounded range model.
void
setMinimum(int minimum)
Changes the current minimal value of this bounded range model.
void
setRangeProperties(int value, int extent, int minimum, int maximum, boolean isAdjusting)
Sets all properties.
void
setValue(int value)
Changes the current value of this bounded range model.
void
setValueIsAdjusting(boolean isAdjusting)
Specifies whether or not the value of this bounded range model is going to change in the immediate future.
String
toString()
Returns a string with all relevant properties of this range model.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

changeEvent

protected ChangeEvent changeEvent
An event that is sent to all registered ChangeListeners when the state of this range model has changed.

The event object is created on demand, the first time it is actually needed.


listenerList

protected EventListenerList listenerList
The list of the currently registered EventListeners.

Constructor Details

DefaultBoundedRangeModel

public DefaultBoundedRangeModel()
Constructs a DefaultBoundedRangeModel with default values for the properties. The properties value, extent and minimum will be initialized to zero; maximum will be set to 100; the property valueIsAdjusting will be false.

DefaultBoundedRangeModel

public DefaultBoundedRangeModel(int value,
                                int extent,
                                int minimum,
                                int maximum)
Constructs a DefaultBoundedRangeModel with the specified values for some properties.
Parameters:
value - the initial value of the range model, which must be a number between minimum and (maximum - extent). In a scroll bar visualization of a BoundedRangeModel, the value is displayed as the position of the thumb.
extent - the initial extent of the range model, which is a number greater than or equal to zero. In a scroll bar visualization of a BoundedRangeModel, the extent is displayed as the size of the thumb.
minimum - the initial minimal value of the range model.
maximum - the initial maximal value of the range model.
Throws:
IllegalArgumentException - if the following condition is not satisfied: minimum <= value <= value + extent <= maximum.

Method Details

addChangeListener

public void addChangeListener(ChangeListener listener)
Subscribes a ChangeListener to state changes.
Specified by:
addChangeListener in interface BoundedRangeModel
Parameters:
listener - the listener to be subscribed.

extends EventListener> T[] getListeners

public extends EventListener> T[] getListeners(Class listenerType)
Retrieves the current listeners of the specified class.
Parameters:
listenerType - the class of listeners; usually ChangeListener.class.
Returns:
an array with the currently subscribed listeners, or an empty array if there are currently no listeners.
Since:
1.3

fireStateChanged

protected void fireStateChanged()
Sends a ChangeEvent to any registered ChangeListeners.

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns all ChangeListeners that are currently subscribed for changes to this DefaultBoundedRangeModel.
Returns:
an array with the currently subscribed listeners, or an empty array if there are currently no listeners.
Since:
1.4

getExtent

public int getExtent()
Returns the current extent of this bounded range model, which is a number greater than or equal to zero. In a scroll bar visualization of a BoundedRangeModel, the extent is displayed as the size of the thumb.
Specified by:
getExtent in interface BoundedRangeModel
Returns:
the extent

getMaximum

public int getMaximum()
Returns the current maximal value of this bounded range model.
Specified by:
getMaximum in interface BoundedRangeModel
Returns:
the maximum

getMinimum

public int getMinimum()
Returns the current minimal value of this bounded range model.
Specified by:
getMinimum in interface BoundedRangeModel

getValue

public int getValue()
Returns the current value of this bounded range model. In a scroll bar visualization of a BoundedRangeModel, the value is displayed as the position of the thumb.
Specified by:
getValue in interface BoundedRangeModel
Returns:
the value

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns whether or not the value of this bounded range model is going to change in the immediate future. Scroll bars set this property to true while the thumb is being dragged around; when the mouse is relased, they set the property to false and post a final ChangeEvent.
Specified by:
getValueIsAdjusting in interface BoundedRangeModel
Returns:
true if the value will change soon again; false if the value will probably not change soon.

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Cancels the subscription of a ChangeListener.
Specified by:
removeChangeListener in interface BoundedRangeModel
Parameters:
listener - the listener to be unsubscribed.

setExtent

public void setExtent(int extent)
Changes the current extent of this bounded range model. In a scroll bar visualization of a BoundedRangeModel, the extent is displayed as the size of the thumb.
Specified by:
setExtent in interface BoundedRangeModel
Parameters:
extent - the new extent of the range model, which is a number greater than or equal to zero.

setMaximum

public void setMaximum(int maximum)
Changes the current maximal value of this bounded range model.
Specified by:
setMaximum in interface BoundedRangeModel
Parameters:
maximum - the new maximal value.

setMinimum

public void setMinimum(int minimum)
Changes the current minimal value of this bounded range model.
Specified by:
setMinimum in interface BoundedRangeModel
Parameters:
minimum - the new minimal value.

setRangeProperties

public void setRangeProperties(int value,
                               int extent,
                               int minimum,
                               int maximum,
                               boolean isAdjusting)
Sets all properties.
Specified by:
setRangeProperties in interface BoundedRangeModel
Parameters:
value - the new value of the range model. In a scroll bar visualization of a BoundedRangeModel, the value is displayed as the position of the thumb.
extent - the new extent of the range model, which is a number greater than or equal to zero. In a scroll bar visualization of a BoundedRangeModel, the extent is displayed as the size of the thumb.
minimum - the new minimal value of the range model.
maximum - the new maximal value of the range model.
isAdjusting - whether or not the value of this bounded range model is going to change in the immediate future. Scroll bars set this property to true while the thumb is being dragged around; when the mouse is relased, they set the property to false.

setValue

public void setValue(int value)
Changes the current value of this bounded range model. In a scroll bar visualization of a BoundedRangeModel, the value is displayed as the position of the thumb; changing the value of a scroll bar's model thus moves the thumb to a different position.
Specified by:
setValue in interface BoundedRangeModel
Parameters:
value - the value

setValueIsAdjusting

public void setValueIsAdjusting(boolean isAdjusting)
Specifies whether or not the value of this bounded range model is going to change in the immediate future. Scroll bars set this property to true while the thumb is being dragged around; when the mouse is relased, they set the property to false.
Specified by:
setValueIsAdjusting in interface BoundedRangeModel
Parameters:
isAdjusting - true if the value will change soon again; false if the value will probably not change soon.

toString

public String toString()
Returns a string with all relevant properties of this range model.
Overrides:
toString in interface Object
Returns:
a string representing the object

DefaultBoundedRangeModel.java -- Default implementation of BoundedRangeModel. Copyright (C) 2002, 2004, 2005, 2006, Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.