Methods Summary |
---|
java.lang.Object | findNextMatch(java.lang.String substring)Returns the next object that starts with substring .
int max = list.size();
if (max == 0) {
return null;
}
int counter = index;
do {
Object value = list.get(counter);
String string = value.toString();
if (string != null && string.startsWith(substring)) {
return value;
}
counter = (counter + 1) % max;
} while (counter != index);
return null;
|
public java.util.List | getList()Returns the List that defines the sequence for this model.
return list;
|
public java.lang.Object | getNextValue()Returns the next legal value of the underlying sequence or
null if value is already the last element.
return (index >= (list.size() - 1)) ? null : list.get(index + 1);
|
public java.lang.Object | getPreviousValue()Returns the previous element of the underlying sequence or
null if value is already the first element.
return (index <= 0) ? null : list.get(index - 1);
|
public java.lang.Object | getValue()Returns the current element of the sequence.
return list.get(index);
|
public void | setList(java.util.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.
if ((list == null) || (list.size() == 0)) {
throw new IllegalArgumentException("invalid list");
}
if (!list.equals(this.list)) {
this.list = list;
index = 0;
fireStateChanged();
}
|
public void | setValue(java.lang.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");
int index = list.indexOf(elt);
if (index == -1) {
throw new IllegalArgumentException("invalid sequence element");
}
else if (index != this.index) {
this.index = index;
fireStateChanged();
}
|