APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class DefaultBoundedRangeModel

extends Object
implements BoundedRangeModel, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.BoundedRangeModel
Annotations
@SuppressWarnings:serial
Imports
javax.swing.event.*, java.io.Serializable, java.util.EventListener

A generic implementation of BoundedRangeModel.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
David Kloba, Hans Muller
Since
1.2
See Also
BoundedRangeModel

Field Summary

Modifier and TypeField and Description
protected transient ChangeEvent
changeEvent

Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property.

private int
private boolean
protected EventListenerList
listenerList

The listeners waiting for model changes.

private int
private int
private int

Constructor Summary

AccessConstructor and Description
public
DefaultBoundedRangeModel()

Initializes all of the properties with default values.

public
DefaultBoundedRangeModel(int
an int giving the current value
value
,
int
the length of the inner range that begins at the model's value
extent
,
int
an int giving the minimum value
min
,
int
an int giving the maximum value
max
)

Initializes value, extent, minimum and maximum.

Method Summary

Modifier and TypeMethod and Description
public void
addChangeListener(ChangeListener
the ChangeListener to add
l
)

Implements javax.swing.BoundedRangeModel.addChangeListener.

Adds a ChangeListener.

protected void
fireStateChanged()

Runs each ChangeListener's stateChanged method.

public ChangeListener[]

Returns:

all of this model's ChangeListeners or an empty array if no change listeners are currently registered
getChangeListeners
()

Returns an array of all the change listeners registered on this DefaultBoundedRangeModel.

public int

Returns:

the model's extent
getExtent
()

Implements javax.swing.BoundedRangeModel.getExtent.

Returns the model's extent.

public <
the type of EventListener class being requested
T extends EventListener
>
T[]

Returns:

an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added
getListeners
(Class<T>
the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener
listenerType
)

Returns an array of all the objects currently registered as FooListeners upon this model.

public int

Returns:

the model's maximum
getMaximum
()

Implements javax.swing.BoundedRangeModel.getMaximum.

Returns the model's maximum.

public int

Returns:

the model's minimum
getMinimum
()

Implements javax.swing.BoundedRangeModel.getMinimum.

Returns the model's minimum.

public int

Returns:

the model's current value
getValue
()

Implements javax.swing.BoundedRangeModel.getValue.

Returns the model's current value.

public boolean

Returns:

the value of the valueIsAdjusting property
getValueIsAdjusting
()

Implements javax.swing.BoundedRangeModel.getValueIsAdjusting.

Returns true if the value is in the process of changing as a result of actions being taken by the user.

public void
removeChangeListener(ChangeListener
the ChangeListener to remove
l
)

Implements javax.swing.BoundedRangeModel.removeChangeListener.

Removes a ChangeListener.

public void
setExtent(int n)

Implements javax.swing.BoundedRangeModel.setExtent.

Sets the extent to n after ensuring that n is greater than or equal to zero and falls within the model's constraints:

    minimum <= value <= value+extent <= maximum
public void
setMaximum(int n)

Implements javax.swing.BoundedRangeModel.setMaximum.

Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints:

    minimum <= value <= value+extent <= maximum
public void
setMinimum(int n)

Implements javax.swing.BoundedRangeModel.setMinimum.

Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints:

    minimum <= value <= value+extent <= maximum
public void
setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)

Implements javax.swing.BoundedRangeModel.setRangeProperties.

Sets all of the BoundedRangeModel properties after forcing the arguments to obey the usual constraints:

    minimum <= value <= value+extent <= maximum
public void
setValue(int n)

Implements javax.swing.BoundedRangeModel.setValue.

Sets the current value of the model.

public void
setValueIsAdjusting(boolean b)

Implements javax.swing.BoundedRangeModel.setValueIsAdjusting.

Sets the valueIsAdjusting property.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string that displays all of the BoundedRangeModel properties.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

changeEventback to summary
protected transient ChangeEvent changeEvent

Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".

extentback to summary
private int extent
isAdjustingback to summary
private boolean isAdjusting
listenerListback to summary
protected EventListenerList listenerList

The listeners waiting for model changes.

maxback to summary
private int max
minback to summary
private int min
valueback to summary
private int value

Constructor Detail

DefaultBoundedRangeModelback to summary
public DefaultBoundedRangeModel()

Initializes all of the properties with default values. Those values are:

  • value = 0
  • extent = 0
  • minimum = 0
  • maximum = 100
  • adjusting = false
DefaultBoundedRangeModelback to summary
public DefaultBoundedRangeModel(int value, int extent, int min, int max)

Initializes value, extent, minimum and maximum. Adjusting is false. Throws an IllegalArgumentException if the following constraints aren't satisfied:

min <= value <= value+extent <= max
Parameters
value:int

an int giving the current value

extent:int

the length of the inner range that begins at the model's value

min:int

an int giving the minimum value

max:int

an int giving the maximum value

Method Detail

addChangeListenerback to summary
public void addChangeListener(ChangeListener l)

Implements javax.swing.BoundedRangeModel.addChangeListener.

Adds a ChangeListener. The change listeners are run each time any one of the Bounded Range model properties changes.

Parameters
l:ChangeListener

the ChangeListener to add

See Also
removeChangeListener, BoundedRangeModel#addChangeListener
fireStateChangedback to summary
protected void fireStateChanged()

Runs each ChangeListener's stateChanged method.

See Also
setRangeProperties, EventListenerList
getChangeListenersback to summary
public ChangeListener[] getChangeListeners()

Returns an array of all the change listeners registered on this DefaultBoundedRangeModel.

Returns:ChangeListener[]

all of this model's ChangeListeners or an empty array if no change listeners are currently registered

Since
1.4
See Also
addChangeListener, removeChangeListener
getExtentback to summary
public int getExtent()

Implements javax.swing.BoundedRangeModel.getExtent.

Returns the model's extent.

Returns:int

the model's extent

See Also
setExtent, BoundedRangeModel#getExtent
getListenersback to summary
public <T extends EventListener> T[] getListeners(Class<T> listenerType)

Returns an array of all the objects currently registered as FooListeners upon this model. FooListeners are registered using the addFooListener method.

You can specify the listenerType argument with a class literal, such as FooListener.class. For example, you can query a DefaultBoundedRangeModel instance m for its change listeners with the following code:

ChangeListener[] cls = (ChangeListener[])(m.getListeners(ChangeListener.class));
If no such listeners exist, this method returns an empty array.
Parameters
<T>
the type of EventListener class being requested
listenerType:Class<T>

the type of listeners requested; this parameter should specify an interface that descends from java.util.EventListener

Returns:T[]

an array of all objects registered as FooListeners on this model, or an empty array if no such listeners have been added

Exceptions
ClassCastException:
if listenerType doesn't specify a class or interface that implements java.util.EventListener
Since
1.3
See Also
getChangeListeners
getMaximumback to summary
public int getMaximum()

Implements javax.swing.BoundedRangeModel.getMaximum.

Returns the model's maximum.

Returns:int

the model's maximum

See Also
setMaximum, BoundedRangeModel#getMaximum
getMinimumback to summary
public int getMinimum()

Implements javax.swing.BoundedRangeModel.getMinimum.

Returns the model's minimum.

Returns:int

the model's minimum

See Also
setMinimum, BoundedRangeModel#getMinimum
getValueback to summary
public int getValue()

Implements javax.swing.BoundedRangeModel.getValue.

Returns the model's current value.

Returns:int

the model's current value

See Also
setValue, BoundedRangeModel#getValue
getValueIsAdjustingback to summary
public boolean getValueIsAdjusting()

Implements javax.swing.BoundedRangeModel.getValueIsAdjusting.

Returns true if the value is in the process of changing as a result of actions being taken by the user.

Returns:boolean

the value of the valueIsAdjusting property

See Also
setValue, BoundedRangeModel#getValueIsAdjusting
removeChangeListenerback to summary
public void removeChangeListener(ChangeListener l)

Implements javax.swing.BoundedRangeModel.removeChangeListener.

Removes a ChangeListener.

Parameters
l:ChangeListener

the ChangeListener to remove

See Also
addChangeListener, BoundedRangeModel#removeChangeListener
setExtentback to summary
public void setExtent(int n)

Implements javax.swing.BoundedRangeModel.setExtent.

Sets the extent to n after ensuring that n is greater than or equal to zero and falls within the model's constraints:

    minimum <= value <= value+extent <= maximum
See Also
BoundedRangeModel#setExtent
setMaximumback to summary
public void setMaximum(int n)

Implements javax.swing.BoundedRangeModel.setMaximum.

Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints:

    minimum <= value <= value+extent <= maximum
See Also
BoundedRangeModel#setMaximum
setMinimumback to summary
public void setMinimum(int n)

Implements javax.swing.BoundedRangeModel.setMinimum.

Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints:

    minimum <= value <= value+extent <= maximum
See Also
getMinimum, BoundedRangeModel#setMinimum
setRangePropertiesback to summary
public void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)

Implements javax.swing.BoundedRangeModel.setRangeProperties.

Sets all of the BoundedRangeModel properties after forcing the arguments to obey the usual constraints:

    minimum <= value <= value+extent <= maximum

At most, one ChangeEvent is generated.

See Also
BoundedRangeModel#setRangeProperties, setValue, setExtent, setMinimum, setMaximum, setValueIsAdjusting
setValueback to summary
public void setValue(int n)

Implements javax.swing.BoundedRangeModel.setValue.

Sets the current value of the model. For a slider, that determines where the knob appears. Ensures that the new value, n falls within the model's constraints:

    minimum <= value <= value+extent <= maximum
See Also
BoundedRangeModel#setValue
setValueIsAdjustingback to summary
public void setValueIsAdjusting(boolean b)

Implements javax.swing.BoundedRangeModel.setValueIsAdjusting.

Sets the valueIsAdjusting property.

See Also
getValueIsAdjusting, setValue, BoundedRangeModel#setValueIsAdjusting
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string that displays all of the BoundedRangeModel properties.