T
- The type of the elements in the List
.public static class SpinnerValueFactory.ListSpinnerValueFactory<T> extends SpinnerValueFactory<T>
SpinnerValueFactory
implementation designed to iterate through
a list of values.
Note that the default converter
is implemented
simply as shown below, which may be adequate in many cases, but it is important
for users to ensure that this suits their needs (and adjust when necessary):
setConverter(new StringConverter<T>() { @Override public String toString(T value) { if (value == null) { return ""; } return value.toString(); } @Override public T fromString(String string) { return (T) string; } });
SpinnerValueFactory.DoubleSpinnerValueFactory, SpinnerValueFactory.IntegerSpinnerValueFactory, SpinnerValueFactory.ListSpinnerValueFactory<T>, SpinnerValueFactory.LocalDateSpinnerValueFactory, SpinnerValueFactory.LocalTimeSpinnerValueFactory
Modifier and Type | Field and Description |
---|---|
private int |
currentIndex
*
Private fields *
*
|
private ObjectProperty<ObservableList<T>> |
items
*
Properties *
*
|
private ListChangeListener<T> |
itemsContentObserver |
private WeakListChangeListener<T> |
weakItemsContentObserver |
Constructor and Description |
---|
ListSpinnerValueFactory(ObservableList<T> items)
Creates a new instance of the ListSpinnerValueFactory with the given
list used as the list to step through.
|
Modifier and Type | Method and Description |
---|---|
private T |
_getValue(int index) |
void |
decrement(int steps)
Attempts to decrement the
value by the given
number of steps. |
ObservableList<T> |
getItems()
Returns an
ObservableList that contains the items currently able
to be iterated through by the user. |
private int |
getItemsSize()
*
Private implementation *
*
|
void |
increment(int steps)
Attempts to omcrement the
value by the given
number of steps. |
ObjectProperty<ObservableList<T>> |
itemsProperty()
The underlying data model for the ListView.
|
void |
setItems(ObservableList<T> value)
Sets the underlying data model for the ListSpinnerValueFactory.
|
private void |
updateCurrentIndex() |
converterProperty, getConverter, getValue, isWrapAround, setConverter, setValue, setWrapAround, valueProperty, wrapAroundProperty
private int currentIndex
private final ListChangeListener<T> itemsContentObserver
private WeakListChangeListener<T> weakItemsContentObserver
private ObjectProperty<ObservableList<T>> items
public ListSpinnerValueFactory(ObservableList<T> items)
items
- The list of items to step through with the Spinner.public final void setItems(ObservableList<T> value)
public final ObservableList<T> getItems()
ObservableList
that contains the items currently able
to be iterated through by the user. This may be null if
setItems(javafx.collections.ObservableList)
has previously been
called, however, by default it is an empty ObservableList.public final ObjectProperty<ObservableList<T>> itemsProperty()
public void decrement(int steps)
value
by the given
number of steps.decrement
in class SpinnerValueFactory<T>
steps
- The number of decrements that should be performed on the value.public void increment(int steps)
value
by the given
number of steps.increment
in class SpinnerValueFactory<T>
steps
- The number of increments that should be performed on the value.private int getItemsSize()
private void updateCurrentIndex()
private T _getValue(int index)