- All Known Implementing Classes:
AbstractSpinnerModel,SpinnerDateModel,SpinnerListModel,SpinnerNumberModel
public interface SpinnerModel
A model for a potentially unbounded sequence of object values. This model
is similar to
ListModel however there are some important differences:
- The number of sequence elements isn't necessarily 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 SpinnerModel has 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 preceding element or null if
valueis the first element of the sequence.
value property changes,
ChangeListeners are notified. SpinnerModel may
choose to notify the ChangeListeners under other circumstances.- Since:
- 1.4
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdds aChangeListenerto the model's listener list.Return the object in the sequence that comes after the object returned bygetValue().Return the object in the sequence that comes before the object returned bygetValue().getValue()The current element of the sequence.voidRemoves aChangeListenerfrom the model's listener list.voidChanges current value of the model, typically this value is displayed by theeditorpart of aJSpinner.
-
Method Details
-
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
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.- Parameters:
value- new value for the spinner- Throws:
IllegalArgumentException- ifvalueisn't allowed- See Also:
-
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:
-
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:
-
addChangeListener
Adds aChangeListenerto the model's listener list. TheChangeListenersmust be notified when modelsvaluechanges.- Parameters:
l- the ChangeListener to add- See Also:
-
removeChangeListener
Removes aChangeListenerfrom the model's listener list.- Parameters:
l- the ChangeListener to remove- See Also:
-