Module MaterialFX
Class ListSpinnerModel<T>
java.lang.Object
io.github.palexdev.materialfx.controls.models.spinner.AbstractSpinnerModel<T>
io.github.palexdev.materialfx.controls.models.spinner.ListSpinnerModel<T>
- All Implemented Interfaces:
SpinnerModel<T>
Concrete implementation of
AbstractSpinnerModel to work with lists of any type.
ListSpinnerModel adds the converterProperty() (since we know the kind of data the model will deal with),
and three new properties, itemsProperty(), getCurrentIndex(), incrementProperty().
The model works by keeping the current value's index in the list and updating that index, even
when the list is modified, see updateCurrentIndex(ListChangeListener.Change).
The constructor initializes the model with these values:
- The converter uses toString(T) on the value or empty string if the value is null
- The default value is an empty ObservableList
- The increment is 1
- The initial value is the first element of the list (if not empty)
-
Property Summary
PropertiesTypePropertyDescriptionSpecifies theStringConverterused to convert the spinner value to a String.Specifies the increment/decrement value to add/subtract from the current index when callingnext()orprevious().Specifies the items list.Properties inherited from class io.github.palexdev.materialfx.controls.models.spinner.AbstractSpinnerModel
defaultValue, value -
Field Summary
Fields inherited from class io.github.palexdev.materialfx.controls.models.spinner.AbstractSpinnerModel
defaultValue, value, wrapAround -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSpecifies theStringConverterused to convert the spinner value to a String.Gets the value of the property converter.intintGets the value of the property increment.getItems()Gets the value of the property items.Specifies the increment/decrement value to add/subtract from the current index when callingnext()orprevious().Specifies the items list.voidnext()If the items list is empty exits immediately.voidprevious()If the items list is empty exits immediately.voidreset()Resets the spinner's value to the value specified byAbstractSpinnerModel.defaultValueProperty(), and the current index to -1;voidsetConverter(StringConverter<T> converter) Sets the value of the property converter.voidsetIncrement(int increment) Sets the value of the property increment.voidsetItems(ObservableList<T> items) Sets the value of the property items.Methods inherited from class io.github.palexdev.materialfx.controls.models.spinner.AbstractSpinnerModel
defaultValueProperty, getDefaultValue, getValue, isWrapAround, setDefaultValue, setValue, setWrapAround, valueProperty
-
Property Details
-
converter
- See Also:
-
items
Specifies the items list.- See Also:
-
increment
Specifies the increment/decrement value to add/subtract from the current index when callingnext()orprevious().- See Also:
-
-
Constructor Details
-
ListSpinnerModel
public ListSpinnerModel() -
ListSpinnerModel
-
-
Method Details
-
next
public void next()If the items list is empty exits immediately. Increments the current index byincrementProperty(), if the new index is greater than the list's last index andAbstractSpinnerModel.isWrapAround()is true, the new index will be set to 0, otherwise toitems.size() - 1At the end the value is updated with the new index. -
previous
public void previous()If the items list is empty exits immediately. Decrements the current index byincrementProperty(), if the new index is lesser than 0 andAbstractSpinnerModel.isWrapAround()is true, the new index will be set toitems.size() - 1, otherwise to 0 At the end the value is updated with the new index. -
reset
public void reset()Resets the spinner's value to the value specified byAbstractSpinnerModel.defaultValueProperty(), and the current index to -1;- Specified by:
resetin interfaceSpinnerModel<T>- Overrides:
resetin classAbstractSpinnerModel<T>
-
getConverter
Gets the value of the property converter.- Property description:
-
converterProperty
Description copied from interface:SpinnerModelSpecifies theStringConverterused to convert the spinner value to a String.- See Also:
-
setConverter
Sets the value of the property converter.- Property description:
-
getCurrentIndex
public int getCurrentIndex()- Returns:
- the current value's index in the items list
-
getItems
Gets the value of the property items.- Property description:
- Specifies the items list.
-
itemsProperty
Specifies the items list.- See Also:
-
setItems
Sets the value of the property items.- Property description:
- Specifies the items list.
-
getIncrement
public int getIncrement()Gets the value of the property increment.- Property description:
- Specifies the increment/decrement value to add/subtract from
the current index when calling
next()orprevious().
-
incrementProperty
Specifies the increment/decrement value to add/subtract from the current index when callingnext()orprevious().- See Also:
-
setIncrement
public void setIncrement(int increment) Sets the value of the property increment.- Property description:
- Specifies the increment/decrement value to add/subtract from
the current index when calling
next()orprevious().
-