Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR-209 (Final Approval Ballot)

javax.swing
Interface SpinnerModel

All Known Implementing Classes:
AbstractSpinnerModel

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:

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 value is the last element of the sequence.
previousValue
The preceeding element or null if value is the first element of the sequence.
When the the value property changes, ChangeListeners are notified. SpinnerModel may choose to notify the ChangeListeners under other circumstances.

Since:
1.4
See Also:
JSpinner, AbstractSpinnerModel, SpinnerListModel, SpinnerNumberModel, SpinnerDateModel

Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener to the model's listener list.
 java.lang.Object getNextValue()
          Return the object in the sequence that comes after the object returned by getValue().
 java.lang.Object getPreviousValue()
          Return the object in the sequence that comes before the object returned by getValue().
 java.lang.Object getValue()
          The current element of the sequence.
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener from the model's listener list.
 void setValue(java.lang.Object value)
          Changes current value of the model, typically this value is displayed by the editor part of a JSpinner.
 

Method Detail

getValue

public java.lang.Object getValue()
The current element of the sequence. This element is usually displayed by the editor part of a JSpinner.

Returns:
the current spinner value.
See Also:
setValue(java.lang.Object)

setValue

public void setValue(java.lang.Object value)
Changes current value of the model, typically this value is displayed by the 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.

Throws:
java.lang.IllegalArgumentException - if value isn't allowed
See Also:
getValue()

getNextValue

public java.lang.Object getNextValue()
Return the object in the sequence that comes after the object returned by getValue(). If the end of the sequence has been reached then return null. Calling this method does not effect value.

Returns:
the next legal value or null if one doesn't exist
See Also:
getValue(), getPreviousValue()

getPreviousValue

public java.lang.Object getPreviousValue()
Return the object in the sequence that comes before the object returned by getValue(). If the end of the sequence has been reached then return null. Calling this method does not effect value.

Returns:
the previous legal value or null if one doesn't exist
See Also:
getValue(), getNextValue()

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener to the model's listener list. The ChangeListeners must be notified when models value changes.

Parameters:
l - the ChangeListener to add
See Also:
removeChangeListener(javax.swing.event.ChangeListener)

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener from the model's listener list.

Parameters:
l - the ChangeListener to remove
See Also:
addChangeListener(javax.swing.event.ChangeListener)

JSR-209 (Final Approval Ballot)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 209 specification.