/* * @(#)SpinnerModel.java 1.6 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.swing; import java.awt.event.*; import javax.swing.event.*; /** * 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. * * @see JSpinner * @see AbstractSpinnerModel * @see SpinnerListModel * @see SpinnerNumberModel * @see SpinnerDateModel * * @version 1.6 12/19/03 * @author Hans Muller * @since 1.4 */ public interface SpinnerModel { /** * The current element of the sequence. This element is usually * displayed by the editor part of a JSpinner. * * @return the current spinner value. * @see #setValue */ Object getValue(); /** * 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 IllegalArgumentException if value isn't allowed * @see #getValue */ void setValue(Object value); /** * 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. * * @return the next legal value or null if one doesn't exist * @see #getValue * @see #getPreviousValue */ Object getNextValue(); /** * 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. * * @return the previous legal value or null if one doesn't exist * @see #getValue * @see #getNextValue */ Object getPreviousValue(); /** * Adds a ChangeListener to the model's listener list. The * ChangeListeners must be notified when models value * changes. * * @param l the ChangeListener to add * @see #removeChangeListener */ void addChangeListener(ChangeListener l); /** * Removes a ChangeListener from the model's listener list. * * @param l the ChangeListener to remove * @see #addChangeListener */ void removeChangeListener(ChangeListener l); }