Class DefaultBoundedRangeModel
java.lang.Object
javax.swing.DefaultBoundedRangeModel
- All Implemented Interfaces:
- Serializable,- BoundedRangeModel
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 XMLEncoder.
- Since:
- 1.2
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected ChangeEventOnly oneChangeEventis needed per model instance since the event's only (read-only) state is the source property.protected EventListenerListThe listeners waiting for model changes.
- 
Constructor SummaryConstructorsConstructorDescriptionInitializes all of the properties with default values.DefaultBoundedRangeModel(int value, int extent, int min, int max) Initializes value, extent, minimum and maximum.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds aChangeListener.protected voidRuns eachChangeListener'sstateChangedmethod.Returns an array of all the change listeners registered on thisDefaultBoundedRangeModel.intReturns the model's extent.<T extends EventListener>
 T[]getListeners(Class<T> listenerType) Returns an array of all the objects currently registered asFooListeners upon this model.intReturns the model's maximum.intReturns the model's minimum.intgetValue()Returns the model's current value.booleanReturns true if the value is in the process of changing as a result of actions being taken by the user.voidRemoves aChangeListener.voidsetExtent(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:voidsetMaximum(int n) Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints:voidsetMinimum(int n) Sets the minimum to n after ensuring that n that the other three properties obey the model's constraints:voidsetRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting) Sets all of theBoundedRangeModelproperties after forcing the arguments to obey the usual constraints:voidsetValue(int n) Sets the current value of the model.voidsetValueIsAdjusting(boolean b) Sets thevalueIsAdjustingproperty.toString()Returns a string that displays all of theBoundedRangeModelproperties.
- 
Field Details- 
changeEventOnly oneChangeEventis 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".
- 
listenerListThe listeners waiting for model changes.
 
- 
- 
Constructor Details- 
DefaultBoundedRangeModelpublic DefaultBoundedRangeModel()Initializes all of the properties with default values. Those values are:- value= 0
- extent= 0
- minimum= 0
- maximum= 100
- adjusting= false
 
- 
DefaultBoundedRangeModelpublic DefaultBoundedRangeModel(int value, int extent, int min, int max) Initializes value, extent, minimum and maximum. Adjusting is false. Throws anIllegalArgumentExceptionif the following constraints aren't satisfied:min <= value <= value+extent <= max - Parameters:
- value- an int giving the current value
- extent- the length of the inner range that begins at the model's value
- min- an int giving the minimum value
- max- an int giving the maximum value
 
 
- 
- 
Method Details- 
getValuepublic int getValue()Returns the model's current value.- Specified by:
- getValuein interface- BoundedRangeModel
- Returns:
- the model's current value
- See Also:
 
- 
getExtentpublic int getExtent()Returns the model's extent.- Specified by:
- getExtentin interface- BoundedRangeModel
- Returns:
- the model's extent
- See Also:
 
- 
getMinimumpublic int getMinimum()Returns the model's minimum.- Specified by:
- getMinimumin interface- BoundedRangeModel
- Returns:
- the model's minimum
- See Also:
 
- 
getMaximumpublic int getMaximum()Returns the model's maximum.- Specified by:
- getMaximumin interface- BoundedRangeModel
- Returns:
- the model's maximum
- See Also:
 
- 
setValuepublic 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- Specified by:
- setValuein interface- BoundedRangeModel
- Parameters:
- n- the model's new value
- See Also:
 
- 
setExtentpublic 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- Specified by:
- setExtentin interface- BoundedRangeModel
- Parameters:
- n- the model's new extent
- See Also:
 
- 
setMinimumpublic 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- Specified by:
- setMinimumin interface- BoundedRangeModel
- Parameters:
- n- the model's new minimum
- See Also:
 
- 
setMaximumpublic 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- Specified by:
- setMaximumin interface- BoundedRangeModel
- Parameters:
- n- the model's new maximum
- See Also:
 
- 
setValueIsAdjustingpublic void setValueIsAdjusting(boolean b) Sets thevalueIsAdjustingproperty.- Specified by:
- setValueIsAdjustingin interface- BoundedRangeModel
- Parameters:
- b- true if the upcoming changes to the value property are part of a series
- See Also:
 
- 
getValueIsAdjustingpublic boolean getValueIsAdjusting()Returns true if the value is in the process of changing as a result of actions being taken by the user.- Specified by:
- getValueIsAdjustingin interface- BoundedRangeModel
- Returns:
- the value of the valueIsAdjustingproperty
- See Also:
 
- 
setRangePropertiespublic void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting) Sets all of theBoundedRangeModelproperties after forcing the arguments to obey the usual constraints:minimum <= value <= value+extent <= maximumAt most, one ChangeEventis generated.- Specified by:
- setRangePropertiesin interface- BoundedRangeModel
- Parameters:
- newValue- an int giving the current value
- newExtent- an int giving the amount by which the value can "jump"
- newMin- an int giving the minimum value
- newMax- an int giving the maximum value
- adjusting- a boolean, true if a series of changes are in progress
- See Also:
 
- 
addChangeListenerAdds aChangeListener. The change listeners are run each time any one of the Bounded Range model properties changes.- Specified by:
- addChangeListenerin interface- BoundedRangeModel
- Parameters:
- l- the ChangeListener to add
- See Also:
 
- 
removeChangeListenerRemoves aChangeListener.- Specified by:
- removeChangeListenerin interface- BoundedRangeModel
- Parameters:
- l- the- ChangeListenerto remove
- See Also:
 
- 
getChangeListenersReturns an array of all the change listeners registered on thisDefaultBoundedRangeModel.- Returns:
- all of this model's ChangeListeners or an empty array if no change listeners are currently registered
- Since:
- 1.4
- See Also:
 
- 
fireStateChangedprotected void fireStateChanged()Runs eachChangeListener'sstateChangedmethod.- See Also:
 
- 
toString
- 
getListenersReturns an array of all the objects currently registered asFooListeners upon this model.FooListeners are registered using theaddFooListenermethod.You can specify the listenerTypeargument with a class literal, such asFooListener.class. For example, you can query aDefaultBoundedRangeModelinstancemfor 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.- Type Parameters:
- T- the type of- EventListenerclass being requested
- Parameters:
- listenerType- the type of listeners requested; this parameter should specify an interface that descends from- java.util.EventListener
- Returns:
- an array of all objects registered as
          FooListeners on this model, or an empty array if no such listeners have been added
- Throws:
- ClassCastException- if- listenerTypedoesn't specify a class or interface that implements- java.util.EventListener
- Since:
- 1.3
- See Also:
 
 
-