javax.swing
Interface SpinnerModel

All Known Implementing Classes:
AbstractSpinnerModel, SpinnerDateModel, SpinnerListModel, SpinnerNumberModel

public interface SpinnerModel

The data model that is used in JSpinners.

Since:
1.4

Method Summary
 void addChangeListener(ChangeListener listener)
          Adds a ChangeListener to the list of registered listeners.
 Object getNextValue()
          Returns the next value from the model.
 Object getPreviousValue()
          Returns the previous value from the model.
 Object getValue()
          Returns the current value of the model.
 void removeChangeListener(ChangeListener listener)
          Removes a given ChangeListener from the list of registered listeners.
 void setValue(Object value)
          Sets the current value of the model to that specified.
 

Method Detail

setValue

void setValue(Object value)
Sets the current value of the model to that specified. Implementations can choose to refuse to accept the value and throw an exception instead. For example, a date model may throw invalid dates, or a list model may throw out values which don't exist in the underlying list. Models may also throw out unusual values, such as null. The decision is left to the discretion of the implementator. If the operation succeeds, the implementation should also notify any registered ChangeListeners.

Parameters:
value - The new value of the model.
Throws:
IllegalArgumentException - if the model does not accept the given value.

getValue

Object getValue()
Returns the current value of the model.

Returns:
The current value.

getNextValue

Object getNextValue()
Returns the next value from the model. If the model is bounded, this method may return null when the upper bound is met. The current value is not changed.

Returns:
The next value, or null if there are no more values to retrieve.

getPreviousValue

Object getPreviousValue()
Returns the previous value from the model. If the model is bounded, this method may return null when the lower bound is met. The current value is not changed.

Returns:
The previous value, or null if there are no more values to retrieve.

addChangeListener

void addChangeListener(ChangeListener listener)
Adds a ChangeListener to the list of registered listeners. Each listener is notified when the current value is changed.

Parameters:
listener - The new listener to register.

removeChangeListener

void removeChangeListener(ChangeListener listener)
Removes a given ChangeListener from the list of registered listeners.

Parameters:
listener - The listener to remove.