- java.lang.Object
-
- javax.swing.DefaultBoundedRangeModel
-
- All Implemented Interfaces:
- Serializable, BoundedRangeModel
public class DefaultBoundedRangeModel extends Object implements BoundedRangeModel, Serializable
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 seeXMLEncoder
.- See Also:
BoundedRangeModel
-
-
Field Summary
Fields Modifier and Type Field and Description protected ChangeEvent
changeEvent
Only oneChangeEvent
is needed per model instance since the event's only (read-only) state is the source property.protected EventListenerList
listenerList
The listeners waiting for model changes.
-
Constructor Summary
Constructors Constructor and Description DefaultBoundedRangeModel()
Initializes all of the properties with default values.DefaultBoundedRangeModel(int value, int extent, int min, int max)
Initializes value, extent, minimum and maximum.
-
Method Summary
Methods Modifier and Type Method and Description void
addChangeListener(ChangeListener l)
Adds aChangeListener
.protected void
fireStateChanged()
Runs eachChangeListener
'sstateChanged
method.ChangeListener[]
getChangeListeners()
Returns an array of all the change listeners registered on thisDefaultBoundedRangeModel
.int
getExtent()
Returns the model's extent.<T extends EventListener>
T[]getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListener
s upon this model.int
getMaximum()
Returns the model's maximum.int
getMinimum()
Returns the model's minimum.int
getValue()
Returns the model's current value.boolean
getValueIsAdjusting()
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)
Removes aChangeListener
.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:void
setMaximum(int n)
Sets the maximum to n after ensuring that n that the other three properties obey the model's constraints:void
setMinimum(int n)
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)
Sets all of theBoundedRangeModel
properties after forcing the arguments to obey the usual constraints:void
setValue(int n)
Sets the current value of the model.void
setValueIsAdjusting(boolean b)
Sets thevalueIsAdjusting
property.String
toString()
Returns a string that displays all of theBoundedRangeModel
properties.
-
-
-
Field Detail
-
changeEvent
protected transient ChangeEvent changeEvent
Only oneChangeEvent
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".
-
listenerList
protected EventListenerList listenerList
The listeners waiting for model changes.
-
-
Constructor Detail
-
DefaultBoundedRangeModel
public DefaultBoundedRangeModel()
Initializes all of the properties with default values. Those values are:value
= 0extent
= 0minimum
= 0maximum
= 100adjusting
= false
-
DefaultBoundedRangeModel
public DefaultBoundedRangeModel(int value, int extent, int min, int max)
Initializes value, extent, minimum and maximum. Adjusting is false. Throws anIllegalArgumentException
if the following constraints aren't satisfied:min <= value <= value+extent <= max
-
-
Method Detail
-
getValue
public int getValue()
Returns the model's current value.- Specified by:
getValue
in interfaceBoundedRangeModel
- Returns:
- the model's current value
- See Also:
setValue(int)
,BoundedRangeModel.getValue()
-
getExtent
public int getExtent()
Returns the model's extent.- Specified by:
getExtent
in interfaceBoundedRangeModel
- Returns:
- the model's extent
- See Also:
setExtent(int)
,BoundedRangeModel.getExtent()
-
getMinimum
public int getMinimum()
Returns the model's minimum.- Specified by:
getMinimum
in interfaceBoundedRangeModel
- Returns:
- the model's minimum
- See Also:
setMinimum(int)
,BoundedRangeModel.getMinimum()
-
getMaximum
public int getMaximum()
Returns the model's maximum.- Specified by:
getMaximum
in interfaceBoundedRangeModel
- Returns:
- the model's maximum
- See Also:
setMaximum(int)
,BoundedRangeModel.getMaximum()
-
setValue
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
- Specified by:
setValue
in interfaceBoundedRangeModel
- Parameters:
n
- the model's new value- See Also:
BoundedRangeModel.setValue(int)
-
setExtent
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
- Specified by:
setExtent
in interfaceBoundedRangeModel
- Parameters:
n
- the model's new extent- See Also:
BoundedRangeModel.setExtent(int)
-
setMinimum
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
- Specified by:
setMinimum
in interfaceBoundedRangeModel
- Parameters:
n
- the model's new minimum- See Also:
getMinimum()
,BoundedRangeModel.setMinimum(int)
-
setMaximum
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
- Specified by:
setMaximum
in interfaceBoundedRangeModel
- Parameters:
n
- the model's new maximum- See Also:
BoundedRangeModel.setMaximum(int)
-
setValueIsAdjusting
public void setValueIsAdjusting(boolean b)
Sets thevalueIsAdjusting
property.- Specified by:
setValueIsAdjusting
in interfaceBoundedRangeModel
- Parameters:
b
- true if the upcoming changes to the value property are part of a series- See Also:
getValueIsAdjusting()
,setValue(int)
,BoundedRangeModel.setValueIsAdjusting(boolean)
-
getValueIsAdjusting
public 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:
getValueIsAdjusting
in interfaceBoundedRangeModel
- Returns:
- the value of the
valueIsAdjusting
property - See Also:
setValue(int)
,BoundedRangeModel.getValueIsAdjusting()
-
setRangeProperties
public void setRangeProperties(int newValue, int newExtent, int newMin, int newMax, boolean adjusting)
Sets all of theBoundedRangeModel
properties after forcing the arguments to obey the usual constraints:minimum <= value <= value+extent <= maximum
At most, one
ChangeEvent
is generated.- Specified by:
setRangeProperties
in interfaceBoundedRangeModel
- Parameters:
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 valueadjusting
- a boolean, true if a series of changes are in progress- See Also:
BoundedRangeModel.setRangeProperties(int, int, int, int, boolean)
,setValue(int)
,setExtent(int)
,setMinimum(int)
,setMaximum(int)
,setValueIsAdjusting(boolean)
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds aChangeListener
. The change listeners are run each time any one of the Bounded Range model properties changes.- Specified by:
addChangeListener
in interfaceBoundedRangeModel
- Parameters:
l
- the ChangeListener to add- See Also:
removeChangeListener(javax.swing.event.ChangeListener)
,BoundedRangeModel.addChangeListener(javax.swing.event.ChangeListener)
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes aChangeListener
.- Specified by:
removeChangeListener
in interfaceBoundedRangeModel
- Parameters:
l
- theChangeListener
to remove- See Also:
addChangeListener(javax.swing.event.ChangeListener)
,BoundedRangeModel.removeChangeListener(javax.swing.event.ChangeListener)
-
getChangeListeners
public ChangeListener[] getChangeListeners()
Returns an array of all the change listeners registered on thisDefaultBoundedRangeModel
.- Returns:
- all of this model's
ChangeListener
s or an empty array if no change listeners are currently registered - Since:
- 1.4
- See Also:
addChangeListener(javax.swing.event.ChangeListener)
,removeChangeListener(javax.swing.event.ChangeListener)
-
fireStateChanged
protected void fireStateChanged()
Runs eachChangeListener
'sstateChanged
method.
-
toString
public String toString()
Returns a string that displays all of theBoundedRangeModel
properties.
-
getListeners
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered asFooListener
s upon this model.FooListener
s are registered using theaddFooListener
method.You can specify the
listenerType
argument with a class literal, such asFooListener.class
. For example, you can query aDefaultBoundedRangeModel
instancem
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:
listenerType
- the type of listeners requested; this parameter should specify an interface that descends fromjava.util.EventListener
- Returns:
- an array of all objects registered as
FooListener
s on this model, or an empty array if no such listeners have been added - Throws:
ClassCastException
- iflistenerType
doesn't specify a class or interface that implementsjava.util.EventListener
- Since:
- 1.3
- See Also:
getChangeListeners()
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
22/11/2024 02:49:38 Cette version de la page est en cache (à la date du 22/11/2024 02:49:38) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/DefaultBoundedRangeModel.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.