Methods Summary |
---|
public void | addChangeListener(javax.swing.event.ChangeListener l)Adds a ChangeListener . The change listeners are run each
time any one of the Bounded Range model properties changes.
listenerList.add(ChangeListener.class, l);
|
protected void | fireStateChanged()Runs each ChangeListener 's stateChanged method.
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -=2 ) {
if (listeners[i] == ChangeListener.class) {
if (changeEvent == null) {
changeEvent = new ChangeEvent(this);
}
((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
}
}
|
public javax.swing.event.ChangeListener[] | getChangeListeners()Returns an array of all the change listeners
registered on this DefaultBoundedRangeModel .
return (ChangeListener[])listenerList.getListeners(
ChangeListener.class);
|
public int | getExtent()Returns the model's extent.
return extent;
|
public T[] | getListeners(java.lang.Class listenerType)Returns an array of all the objects currently registered as
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.
return listenerList.getListeners(listenerType);
|
public int | getMaximum()Returns the model's maximum.
return max;
|
public int | getMinimum()Returns the model's minimum.
return min;
|
public int | getValue()Returns the model's current value.
return value;
|
public boolean | getValueIsAdjusting()Returns true if the value is in the process of changing
as a result of actions being taken by the user.
return isAdjusting;
|
public void | removeChangeListener(javax.swing.event.ChangeListener l)Removes a ChangeListener .
listenerList.remove(ChangeListener.class, l);
|
public void | setExtent(int n)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
int newExtent = Math.max(0, n);
if(value + newExtent > max) {
newExtent = max - value;
}
setRangeProperties(value, newExtent, min, max, isAdjusting);
|
public void | setMaximum(int n)Sets the maximum to n after ensuring that n
that the other three properties obey the model's constraints:
minimum <= value <= value+extent <= maximum
int newMin = Math.min(n, min);
int newExtent = Math.min(n - newMin, extent);
int newValue = Math.min(n - newExtent, value);
setRangeProperties(newValue, newExtent, newMin, n, isAdjusting);
|
public void | setMinimum(int n)Sets the minimum to n after ensuring that n
that the other three properties obey the model's constraints:
minimum <= value <= value+extent <= maximum
int newMax = Math.max(n, max);
int newValue = Math.max(n, value);
int newExtent = Math.min(newMax - newValue, extent);
setRangeProperties(newValue, newExtent, n, newMax, isAdjusting);
|
public void | setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)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.
if (newMin > newMax) {
newMin = newMax;
}
if (newValue > newMax) {
newMax = newValue;
}
if (newValue < newMin) {
newMin = newValue;
}
/* Convert the addends to long so that extent can be
* Integer.MAX_VALUE without rolling over the sum.
* A JCK test covers this, see bug 4097718.
*/
if (((long)newExtent + (long)newValue) > newMax) {
newExtent = newMax - newValue;
}
if (newExtent < 0) {
newExtent = 0;
}
boolean isChange =
(newValue != value) ||
(newExtent != extent) ||
(newMin != min) ||
(newMax != max) ||
(adjusting != isAdjusting);
if (isChange) {
value = newValue;
extent = newExtent;
min = newMin;
max = newMax;
isAdjusting = adjusting;
fireStateChanged();
}
|
public void | setValue(int n)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
n = Math.min(n, Integer.MAX_VALUE - extent);
int newValue = Math.max(n, min);
if (newValue + extent > max) {
newValue = max - extent;
}
setRangeProperties(newValue, extent, min, max, isAdjusting);
|
public void | setValueIsAdjusting(boolean b)Sets the valueIsAdjusting property.
setRangeProperties(value, extent, min, max, b);
|
public java.lang.String | toString()Returns a string that displays all of the
BoundedRangeModel properties.
String modelString =
"value=" + getValue() + ", " +
"extent=" + getExtent() + ", " +
"min=" + getMinimum() + ", " +
"max=" + getMaximum() + ", " +
"adj=" + getValueIsAdjusting();
return getClass().getName() + "[" + modelString + "]";
|