-
- All Known Implementing Classes:
- AbstractSpinnerModel, SpinnerDateModel, SpinnerListModel, SpinnerNumberModel
public interface SpinnerModelA model for a potentially unbounded sequence of object values. This model is similar toListModelhowever there are some important differences:- The number of sequence elements isn't neccessarily bounded.
- The model doesn't support indexed random access to sequence elements. Only three sequence values are accessible at a time: current, next and previous.
- The current sequence element, can be set.
A
SpinnerModelhas three properties, only the first is read/write.value- The current element of the sequence.
nextValue- The following element or null if
valueis the last element of the sequence. previousValue- The preceeding element or null if
valueis the first element of the sequence.
valueproperty changes,ChangeListenersare notified.SpinnerModelmay choose to notify theChangeListenersunder other circumstances.- Since:
- 1.4
- See Also:
JSpinner,AbstractSpinnerModel,SpinnerListModel,SpinnerNumberModel,SpinnerDateModel
-
-
Method Summary
Methods Modifier and Type Method and Description voidaddChangeListener(ChangeListener l)Adds aChangeListenerto the model's listener list.ObjectgetNextValue()Return the object in the sequence that comes after the object returned bygetValue().ObjectgetPreviousValue()Return the object in the sequence that comes before the object returned bygetValue().ObjectgetValue()The current element of the sequence.voidremoveChangeListener(ChangeListener l)Removes aChangeListenerfrom the model's listener list.voidsetValue(Object value)Changes current value of the model, typically this value is displayed by theeditorpart of aJSpinner.
-
-
-
Method Detail
-
getValue
Object getValue()
The current element of the sequence. This element is usually displayed by theeditorpart of aJSpinner.- Returns:
- the current spinner value.
- See Also:
setValue(java.lang.Object)
-
setValue
void setValue(Object value)
Changes current value of the model, typically this value is displayed by theeditorpart of aJSpinner. If theSpinnerModelimplementation doesn't support the specified value then anIllegalArgumentExceptionis thrown. For example aSpinnerModelfor numbers might only support values that are integer multiples of ten. In that case,model.setValue(new Number(11))would throw an exception.- Throws:
IllegalArgumentException- ifvalueisn't allowed- See Also:
getValue()
-
getNextValue
Object getNextValue()
Return the object in the sequence that comes after the object returned bygetValue(). If the end of the sequence has been reached then return null. Calling this method does not effectvalue.- Returns:
- the next legal value or null if one doesn't exist
- See Also:
getValue(),getPreviousValue()
-
getPreviousValue
Object getPreviousValue()
Return the object in the sequence that comes before the object returned bygetValue(). If the end of the sequence has been reached then return null. Calling this method does not effectvalue.- Returns:
- the previous legal value or null if one doesn't exist
- See Also:
getValue(),getNextValue()
-
addChangeListener
void addChangeListener(ChangeListener l)
Adds aChangeListenerto the model's listener list. TheChangeListenersmust be notified when modelsvaluechanges.- Parameters:
l- the ChangeListener to add- See Also:
removeChangeListener(javax.swing.event.ChangeListener)
-
removeChangeListener
void removeChangeListener(ChangeListener l)
Removes aChangeListenerfrom the model's listener list.- Parameters:
l- the ChangeListener to remove- See Also:
addChangeListener(javax.swing.event.ChangeListener)
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-javax/swing/spinnermodel.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author of this site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.