This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing
class SpinnerListModel

java.lang.Object extended by javax.swing.AbstractSpinnerModel extended by javax.swing.SpinnerListModel
All Implemented Interfaces:
Serializable, SpinnerModel

public class SpinnerListModel
extends AbstractSpinnerModel
implements Serializable

A simple implementation of SpinnerModel whose values are defined by an array or a List. For example to create a model defined by an array of the names of the days of the week:

 String[] days = new DateFormatSymbols().getWeekdays();
 SpinnerModel model = new SpinnerListModel(Arrays.asList(days).subList(1, 8));
 
This class only stores a reference to the array or List so if an element of the underlying sequence changes, it's up to the application to notify the ChangeListeners by calling fireStateChanged.

This model inherits a ChangeListener. The ChangeListeners are notified whenever the model's value or list properties changes.


Field Summary
 
Fields inherited from class javax.swing.AbstractSpinnerModel
listenerList
 
Constructor Summary

          Constructs an effectively empty SpinnerListModel.

          Constructs a SpinnerModel whose sequence of values is defined by the specified List.

          Constructs a SpinnerModel whose sequence of values is defined by the specified array.
 
Method Summary
 List

          Returns the List that defines the sequence for this model.
 Object

          Returns the next legal value of the underlying sequence or null if value is already the last element.
 Object

          Returns the previous element of the underlying sequence or null if value is already the first element.
 Object

          Returns the current element of the sequence.
 void
setList(List list)

          Changes the list that defines this sequence and resets the index of the models value to zero.
 void

          Changes the current element of the sequence and notifies ChangeListeners.
 
Methods inherited from class javax.swing.AbstractSpinnerModel
addChangeListener, fireStateChanged, getChangeListeners, getListeners, removeChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpinnerListModel

public SpinnerListModel()
Constructs an effectively empty SpinnerListModel. The model's list will contain a single "empty" string element.


SpinnerListModel

public SpinnerListModel(List values)
Constructs a SpinnerModel whose sequence of values is defined by the specified List. The initial value (current element) of the model will be values.get(0). If values is null or has zero size, an IllegalArugmentException is thrown.

Parameters:
values - the sequence this model represents

SpinnerListModel

public SpinnerListModel(Object[] values)
Constructs a SpinnerModel whose sequence of values is defined by the specified array. The initial value of the model will be values[0]. If values is null or has zero length, an IllegalArugmentException is thrown.

Parameters:
values - the sequence this model represents
Method Detail

getList

public List getList()
Returns the List that defines the sequence for this model.

Returns:
the value of the list property

getNextValue

public Object getNextValue()
Returns the next legal value of the underlying sequence or null if value is already the last element.

Returns:
the next legal value of the underlying sequence or null if value is already the last element

getPreviousValue

public Object getPreviousValue()
Returns the previous element of the underlying sequence or null if value is already the first element.

Returns:
the previous element of the underlying sequence or null if value is already the first element

getValue

public Object getValue()
Returns the current element of the sequence.

Returns:
the value property

setList

public void setList(List list)
Changes the list that defines this sequence and resets the index of the models value to zero. Note that list is not copied, the model just stores a reference to it.

This method fires a ChangeEvent if list is not equal to the current list.

Parameters:
list - the sequence that this model represents

setValue

public void setValue(Object elt)
Changes the current element of the sequence and notifies ChangeListeners. If the specified value is not equal to an element of the underlying sequence then an IllegalArgumentException is thrown. In the following example the setValue call would cause an exception to be thrown:
 String[] values = {"one", "two", "free", "four"};
 SpinnerModel model = new SpinnerListModel(values);
 model.setValue("TWO");
 

Parameters:
elt - the sequence element that will be model's current value


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.