|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.DefaultBoundedRangeModel
Safe: 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 JavaBeansTM
has been added to the java.beans
package.
Please see java.beans.XMLEncoder
.
BoundedRangeModel
,
Serialized FormField Summary | |
protected ChangeEvent |
changeEvent
Only one ChangeEvent is needed per model instance since the
event's only (read-only) state is the source property. |
private int |
extent
|
private boolean |
isAdjusting
|
protected EventListenerList |
listenerList
The listeners waiting for model changes. |
private int |
max
|
private int |
min
|
private int |
value
|
Constructor Summary | |
DefaultBoundedRangeModel()
Enabled: Initializes all of the properties with default values. |
|
DefaultBoundedRangeModel(int value,
int extent,
int min,
int max)
Enabled: Initializes value, extent, minimum and maximum. |
Method Summary | |
void |
addChangeListener(ChangeListener l)
Enabled: Adds a ChangeListener . |
protected void |
fireStateChanged()
Runs each ChangeListener 's stateChanged method. |
ChangeListener[] |
getChangeListeners()
Suppressed: Returns an array of all the change listeners registered on this DefaultBoundedRangeModel . |
int |
getExtent()
Enabled: Returns the model's extent. |
EventListener[] |
getListeners(Class listenerType)
Suppressed: Returns an array of all the objects currently registered as FooListener s
upon this model. |
int |
getMaximum()
Enabled: Returns the model's maximum. |
int |
getMinimum()
Enabled: Returns the model's minimum. |
int |
getValue()
Enabled: Returns the model's current value. |
boolean |
getValueIsAdjusting()
Enabled: Returns true if the value is in the process of changing as a result of actions being taken by the user. |
void |
removeChangeListener(ChangeListener l)
Enabled: Removes a ChangeListener . |
void |
setExtent(int n)
Enabled: Sets the extent to n after ensuring that n is greater than or equal to zero and falls within the model's constraints: |
void |
setMaximum(int n)
Enabled: Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints: |
void |
setMinimum(int n)
Enabled: Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints: |
void |
setRangeProperties(int newValue,
int newExtent,
int newMin,
int newMax,
boolean adjusting)
Enabled: Sets all of the BoundedRangeModel properties after forcing
the arguments to obey the usual constraints:
|
void |
setValue(int n)
Enabled: Sets the current value of the model. |
void |
setValueIsAdjusting(boolean b)
Enabled: Sets the valueIsAdjusting property. |
String |
toString()
Suppressed: Returns a string that displays all of the BoundedRangeModel properties. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected transient ChangeEvent changeEvent
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".
protected EventListenerList listenerList
private int value
private int extent
private int min
private int max
private boolean isAdjusting
Constructor Detail |
public DefaultBoundedRangeModel()
value
= 0
extent
= 0
minimum
= 0
maximum
= 100
adjusting
= false
public DefaultBoundedRangeModel(int value, int extent, int min, int max)
IllegalArgumentException
if the following
constraints aren't satisfied:
min <= value <= value+extent <= max
Method Detail |
public int getValue()
getValue
in interface BoundedRangeModel
setValue(int)
,
BoundedRangeModel.getValue()
public int getExtent()
getExtent
in interface BoundedRangeModel
setExtent(int)
,
BoundedRangeModel.getExtent()
public int getMinimum()
getMinimum
in interface BoundedRangeModel
setMinimum(int)
,
BoundedRangeModel.getMinimum()
public int getMaximum()
getMaximum
in interface BoundedRangeModel
setMaximum(int)
,
BoundedRangeModel.getMaximum()
public void setValue(int n)
minimum <= value <= value+extent <= maximum
setValue
in interface BoundedRangeModel
n
- the model's new valueBoundedRangeModel.setValue(int)
public void setExtent(int n)
minimum <= value <= value+extent <= maximum
setExtent
in interface BoundedRangeModel
n
- the model's new extentBoundedRangeModel.setExtent(int)
public void setMinimum(int n)
minimum <= value <= value+extent <= maximum
setMinimum
in interface BoundedRangeModel
n
- the model's new minimumgetMinimum()
,
BoundedRangeModel.setMinimum(int)
public void setMaximum(int n)
minimum <= value <= value+extent <= maximum
setMaximum
in interface BoundedRangeModel
n
- the model's new maximumBoundedRangeModel.setMaximum(int)
public void setValueIsAdjusting(boolean b)
valueIsAdjusting
property.
setValueIsAdjusting
in interface BoundedRangeModel
b
- true if the upcoming changes to the value property are part of a seriesgetValueIsAdjusting()
,
setValue(int)
,
BoundedRangeModel.setValueIsAdjusting(boolean)
public boolean getValueIsAdjusting()
getValueIsAdjusting
in interface BoundedRangeModel
valueIsAdjusting
propertysetValue(int)
,
BoundedRangeModel.getValueIsAdjusting()
public void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)
BoundedRangeModel
properties after forcing
the arguments to obey the usual constraints:
minimum <= value <= value+extent <= maximum
At most, one ChangeEvent
is generated.
setRangeProperties
in interface BoundedRangeModel
newValue
- an int giving the current valuenewExtent
- an int giving the amount by which the value can "jump"newMin
- an int giving the minimum valuenewMax
- an int giving the maximum valueBoundedRangeModel.setRangeProperties(int, int, int, int, boolean)
,
setValue(int)
,
setExtent(int)
,
setMinimum(int)
,
setMaximum(int)
,
setValueIsAdjusting(boolean)
public void addChangeListener(ChangeListener l)
ChangeListener
. The change listeners are run each
time any one of the Bounded Range model properties changes.
addChangeListener
in interface BoundedRangeModel
l
- the ChangeListener to addremoveChangeListener(javax.swing.event.ChangeListener)
,
BoundedRangeModel.addChangeListener(javax.swing.event.ChangeListener)
public void removeChangeListener(ChangeListener l)
ChangeListener
.
removeChangeListener
in interface BoundedRangeModel
l
- the ChangeListener
to removeaddChangeListener(javax.swing.event.ChangeListener)
,
BoundedRangeModel.removeChangeListener(javax.swing.event.ChangeListener)
public ChangeListener[] getChangeListeners()
DefaultBoundedRangeModel
.
ChangeListener
s
or an empty
array if no change listeners are currently registeredaddChangeListener(javax.swing.event.ChangeListener)
,
removeChangeListener(javax.swing.event.ChangeListener)
protected void fireStateChanged()
ChangeListener
's stateChanged
method.
setRangeProperties(int, int, int, int, boolean)
,
EventListenerList
public String toString()
BoundedRangeModel
properties.
toString
in class Object
public EventListener[] getListeners(Class listenerType)
FooListener
s
upon this model.
FooListener
s
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.
listenerType
- the type of listeners requested;
this parameter should specify an interface
that descends from java.util.EventListener
FooListener
s
on this model,
or an empty array if no such
listeners have been addedgetChangeListeners()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |