- 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()
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/defaultboundedrangemodel.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.