AbstractSpinnerModel
, SpinnerDateModel
, SpinnerListModel
, SpinnerNumberModel
public interface SpinnerModel
ListModel
however there are some important differences: A SpinnerModel
has three properties, only the first is read/write.
value
nextValue
value
is the last element of the sequence. previousValue
value
is the first element of the sequence. value
property changes, ChangeListeners
are notified. SpinnerModel
may choose to notify the ChangeListeners
under other circumstances.Modifier and Type | Method | Description |
---|---|---|
void |
addChangeListener |
Adds a ChangeListener to the model's listener list. |
Object |
getNextValue() |
Return the object in the sequence that comes after the object returned by getValue() . |
Object |
getPreviousValue() |
Return the object in the sequence that comes before the object returned by getValue() . |
Object |
getValue() |
The current element of the sequence. |
void |
removeChangeListener |
Removes a ChangeListener from the model's listener list. |
void |
setValue |
Changes current value of the model, typically this value is displayed by the editor part of a JSpinner . |
Object getValue()
editor
part of a JSpinner
.void setValue(Object value)
editor
part of a JSpinner
. If the SpinnerModel
implementation doesn't support the specified value then an IllegalArgumentException
is thrown. For example a SpinnerModel
for numbers might only support values that are integer multiples of ten. In that case, model.setValue(new Number(11))
would throw an exception.value
- new value for the spinnerIllegalArgumentException
- if value
isn't allowedObject getNextValue()
getValue()
. If the end of the sequence has been reached then return null. Calling this method does not effect value
.Object getPreviousValue()
getValue()
. If the end of the sequence has been reached then return null. Calling this method does not effect value
.void addChangeListener(ChangeListener l)
ChangeListener
to the model's listener list. The ChangeListeners
must be notified when models value
changes.l
- the ChangeListener to addvoid removeChangeListener(ChangeListener l)
ChangeListener
from the model's listener list.l
- the ChangeListener to remove
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/SpinnerModel.html