src/share/classes/javax/swing/SpinnerListModel.java

Print this page




  42  * so if an element of the underlying sequence changes, it's up
  43  * to the application to notify the <code>ChangeListeners</code> by calling
  44  * <code>fireStateChanged</code>.
  45  * <p>
  46  * This model inherits a <code>ChangeListener</code>.
  47  * The <code>ChangeListener</code>s are notified whenever the
  48  * model's <code>value</code> or <code>list</code> properties changes.
  49  *
  50  * @see JSpinner
  51  * @see SpinnerModel
  52  * @see AbstractSpinnerModel
  53  * @see SpinnerNumberModel
  54  * @see SpinnerDateModel
  55  *
  56  * @author Hans Muller
  57  * @since 1.4
  58  */
  59 @SuppressWarnings("serial") // Superclass is not serializable across versions
  60 public class SpinnerListModel extends AbstractSpinnerModel implements Serializable
  61 {
  62     private List list;
  63     private int index;
  64 
  65 
  66     /**
  67      * Constructs a <code>SpinnerModel</code> whose sequence of
  68      * values is defined by the specified <code>List</code>.
  69      * The initial value (<i>current element</i>)
  70      * of the model will be <code>values.get(0)</code>.
  71      * If <code>values</code> is <code>null</code> or has zero
  72      * size, an <code>IllegalArugmentException</code> is thrown.
  73      *
  74      * @param values the sequence this model represents
  75      * @throws IllegalArgumentException if <code>values</code> is
  76      *    <code>null</code> or zero size
  77      */
  78     public SpinnerListModel(List<?> values) {
  79         if (values == null || values.size() == 0) {
  80             throw new IllegalArgumentException("SpinnerListModel(List) expects non-null non-empty List");
  81         }
  82         this.list = values;




  42  * so if an element of the underlying sequence changes, it's up
  43  * to the application to notify the <code>ChangeListeners</code> by calling
  44  * <code>fireStateChanged</code>.
  45  * <p>
  46  * This model inherits a <code>ChangeListener</code>.
  47  * The <code>ChangeListener</code>s are notified whenever the
  48  * model's <code>value</code> or <code>list</code> properties changes.
  49  *
  50  * @see JSpinner
  51  * @see SpinnerModel
  52  * @see AbstractSpinnerModel
  53  * @see SpinnerNumberModel
  54  * @see SpinnerDateModel
  55  *
  56  * @author Hans Muller
  57  * @since 1.4
  58  */
  59 @SuppressWarnings("serial") // Superclass is not serializable across versions
  60 public class SpinnerListModel extends AbstractSpinnerModel implements Serializable
  61 {
  62     private List<?> list;
  63     private int index;
  64 
  65 
  66     /**
  67      * Constructs a <code>SpinnerModel</code> whose sequence of
  68      * values is defined by the specified <code>List</code>.
  69      * The initial value (<i>current element</i>)
  70      * of the model will be <code>values.get(0)</code>.
  71      * If <code>values</code> is <code>null</code> or has zero
  72      * size, an <code>IllegalArugmentException</code> is thrown.
  73      *
  74      * @param values the sequence this model represents
  75      * @throws IllegalArgumentException if <code>values</code> is
  76      *    <code>null</code> or zero size
  77      */
  78     public SpinnerListModel(List<?> values) {
  79         if (values == null || values.size() == 0) {
  80             throw new IllegalArgumentException("SpinnerListModel(List) expects non-null non-empty List");
  81         }
  82         this.list = values;