Class Spinner<T>

java.lang.Object
Type Parameters:
T - The type of all values that can be iterated through in the Spinner. Common types include Integer and String.
All Implemented Interfaces:
Styleable, EventTarget, Skinnable

public class Spinner<T> extends Control
A single line text field that lets the user select a number or an object value from an ordered sequence. Spinners typically provide a pair of tiny arrow buttons for stepping through the elements of the sequence. The keyboard up/down arrow keys also cycle through the elements. The user may also be allowed to type a (legal) value directly into the spinner. Although combo boxes provide similar functionality, spinners are sometimes preferred because they don't require a drop down list that can obscure important data, and also because they allow for features such as wrapping and simpler specification of 'infinite' data models (the SpinnerValueFactory, rather than using a ObservableList data model like many other JavaFX UI controls.

A Spinner's sequence value is defined by its SpinnerValueFactory. The value factory can be specified as a constructor argument and changed with the value factory property. SpinnerValueFactory classes for some common types are provided with JavaFX, including:

A Spinner has a TextField child component that is responsible for displaying and potentially changing the current value of the Spinner, which is called the editor. By default the Spinner is non-editable, but input can be accepted if the editable property is set to true. The Spinner editor stays in sync with the value factory by listening for changes to the value property of the value factory. If the user has changed the value displayed in the editor it is possible for the Spinner value to differ from that of the editor. To make sure the model has the same value as the editor, the user must commit the edit using the Enter key.

Example:

Spinner spinner = new Spinner(0, 10, 5);
Image of the Spinner control
Since:
JavaFX 8u40
See Also: