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:
SpinnerValueFactory.IntegerSpinnerValueFactory SpinnerValueFactory.DoubleSpinnerValueFactory SpinnerValueFactory.ListSpinnerValueFactory 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);
SpinnerValueFactory
| Modifier and Type | Field and Description |
|---|---|
| private final ChangeListener | |
| private static final String | |
| private BooleanProperty | |
| private ReadOnlyObjectWrapper | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| private static final CssMetaData | |
| private final ObjectProperty | |
| public static final String | STYLE_CLASS_ARROWS_ON_LEFT_HORIZONTAL
The arrows are placed on the left of the Spinner, pointing horizontally (i.e. left and right). |
| public static final String | STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL
The arrows are placed on the left of the Spinner, pointing vertically (i.e. up and down). |
| public static final String | STYLE_CLASS_ARROWS_ON_RIGHT_HORIZONTAL
The arrows are placed on the right of the Spinner, pointing horizontally (i.e. left and right). |
| public static final String | STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL
The decrement arrow is placed on the left of the Spinner, and the increment on the right. |
| public static final String | STYLE_CLASS_SPLIT_ARROWS_VERTICAL
The arrows are placed above and beneath the spinner, stretching to take the entire width. |
| private static final List | |
| private TextField | |
| private ReadOnlyObjectWrapper | value
The value property on Spinner is a read-only property, as it is bound to
the SpinnerValueFactory
|
| private ObjectProperty | valueFactory
The value factory is the model behind the JavaFX Spinner control - without a value factory installed a Spinner is unusable. |
| Access | Constructor and Description |
|---|---|
| public | Spinner()
Constructs a default Spinner instance, with the default 'spinner' style class and a non-editable editor. |
| public | Spinner(int
The minimum allowed integer value for the Spinner. min, int The maximum allowed integer value for the Spinner. max, int The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue)Creates a Spinner instance with the
|
| public | Spinner(int
The minimum allowed integer value for the Spinner. min, int The maximum allowed integer value for the Spinner. max, int The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue, int The amount to increment or decrement by, per step. amountToStepBy)Creates a Spinner instance with the
|
| public | Spinner(double
The minimum allowed double value for the Spinner. min, double The maximum allowed double value for the Spinner. max, double The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue)Creates a Spinner instance with the
|
| public | Spinner(double
The minimum allowed double value for the Spinner. min, double The maximum allowed double value for the Spinner. max, double The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue, double The amount to increment or decrement by, per step. amountToStepBy)Creates a Spinner instance with the
|
| pack-priv | Spinner(LocalDate
The minimum allowed LocalDate value for the Spinner. min, LocalDate The maximum allowed LocalDate value for the Spinner. max, LocalDate The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue)Creates a Spinner instance with the
|
| pack-priv | Spinner(LocalDate
The minimum allowed LocalDate value for the Spinner. min, LocalDate The maximum allowed LocalDate value for the Spinner. max, LocalDate The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue, long The amount to increment or decrement by, per step. amountToStepBy, TemporalUnit The size of each step (e.g. day, week, month, year, etc). temporalUnit)Creates a Spinner instance with the
|
| pack-priv | Spinner(LocalTime
The minimum allowed LocalTime value for the Spinner. min, LocalTime The maximum allowed LocalTime value for the Spinner. max, LocalTime The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue)Creates a Spinner instance with the
|
| pack-priv | Spinner(LocalTime
The minimum allowed LocalTime value for the Spinner. min, LocalTime The maximum allowed LocalTime value for the Spinner. max, LocalTime The value of the Spinner when first instantiated, must
be within the bounds of the min and max arguments, or
else the min value will be used. initialValue, long The amount to increment or decrement by, per step. amountToStepBy, TemporalUnit The size of each step (e.g. hour, minute, second, etc). temporalUnit)Creates a Spinner instance with the
|
| public | Spinner(ObservableList<T>
A list of items that will be stepped through in the Spinner. items)Creates a Spinner instance with the
|
| public | Spinner(SpinnerValueFactory<T>
The valueFactory)value factory to use.Creates a Spinner instance with the given value factory set. |
| Modifier and Type | Method and Description |
|---|---|
| public final void | cancelEdit()
If the Spinner is |
| public final void | commitValue()
If the Spinner is |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public void | decrement()
Attempts to decrement the |
| public void | decrement(int
The number of decrements that should be performed on the value. steps)Attempts to decrement the |
| public final BooleanProperty | |
| public final ReadOnlyObjectProperty | |
| public void | executeAccessibleAction(AccessibleAction action, Object... parameters)
Overrides javafx. This method is called by the assistive technology to request the action indicated by the argument should be executed. |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final TextField | |
| public final Duration | |
| public final String | |
| public final Duration | |
| public final T | |
| public final SpinnerValueFactory | |
| public void | increment()
Attempts to increment the |
| public void | increment(int
The number of increments that should be performed on the value. steps)Attempts to increment the |
| public final ObjectProperty | Returns: initial delay propertyThe duration that the mouse has to be pressed on an arrow button before the next value steps. |
| public final boolean | |
| public final StringProperty | Returns: the prompt text propertyThe prompt text to display in the |
| public Object | queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)
Overrides javafx. This method is called by the assistive technology to request the value for an attribute. |
| public final ObjectProperty | Returns: repeat delay propertyThe duration that the mouse has to be pressed for each successive step after the first value steps. |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| private void | |
| public final void | |
| public final ObjectProperty | |
| public final ReadOnlyObjectProperty | |
| pack-priv static int | |
| pack-priv static BigDecimal |
| converterListener | back to summary |
|---|---|
| private final ChangeListener<StringConverter<T>> converterListener | |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| editable | back to summary |
|---|---|
| private BooleanProperty editable The editable property is used to specify whether user input is able to
be typed into the Spinner
| |
| editor | back to summary |
|---|---|
| private ReadOnlyObjectWrapper<TextField> editor | |
| INITIAL_DELAY | back to summary |
|---|---|
| private static final CssMetaData<Spinner<?>, Duration> INITIAL_DELAY | |
| initialDelay | back to summary |
|---|---|
| private final ObjectProperty<Duration> initialDelay | |
| REPEAT_DELAY | back to summary |
|---|---|
| private static final CssMetaData<Spinner<?>, Duration> REPEAT_DELAY | |
| repeatDelay | back to summary |
|---|---|
| private final ObjectProperty<Duration> repeatDelay | |
| STYLE_CLASS_ARROWS_ON_LEFT_HORIZONTAL | back to summary |
|---|---|
| public static final String STYLE_CLASS_ARROWS_ON_LEFT_HORIZONTAL The arrows are placed on the left of the Spinner, pointing horizontally (i.e. left and right). | |
| STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL | back to summary |
|---|---|
| public static final String STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL The arrows are placed on the left of the Spinner, pointing vertically (i.e. up and down). | |
| STYLE_CLASS_ARROWS_ON_RIGHT_HORIZONTAL | back to summary |
|---|---|
| public static final String STYLE_CLASS_ARROWS_ON_RIGHT_HORIZONTAL The arrows are placed on the right of the Spinner, pointing horizontally (i.e. left and right). | |
| STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL | back to summary |
|---|---|
| public static final String STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL The decrement arrow is placed on the left of the Spinner, and the increment on the right. | |
| STYLE_CLASS_SPLIT_ARROWS_VERTICAL | back to summary |
|---|---|
| public static final String STYLE_CLASS_SPLIT_ARROWS_VERTICAL The arrows are placed above and beneath the spinner, stretching to take the entire width. | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| textField | back to summary |
|---|---|
| private TextField textField | |
| value | back to summary |
|---|---|
| private ReadOnlyObjectWrapper<T> value The value property on Spinner is a read-only property, as it is bound to
the SpinnerValueFactory
If developers wish to modify the value property, they may do so with code in the following form:
| |
| valueFactory | back to summary |
|---|---|
| private ObjectProperty<SpinnerValueFactory<T>> valueFactory The value factory is the model behind the JavaFX Spinner control - without a value factory installed a Spinner is unusable. It is the role of the value factory to handle almost all aspects of the Spinner, including:
| |
| Spinner | back to summary |
|---|---|
| public Spinner() Constructs a default Spinner instance, with the default 'spinner' style class and a non-editable editor. | |
| Spinner | back to summary |
|---|---|
| public Spinner(int min, int max, int initialValue) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| public Spinner(int min, int max, int initialValue, int amountToStepBy) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| public Spinner(double min, double max, double initialValue) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| public Spinner(double min, double max, double initialValue, double amountToStepBy) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| pack-priv Spinner(LocalDate min, LocalDate max, LocalDate initialValue) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| pack-priv Spinner(LocalDate min, LocalDate max, LocalDate initialValue, long amountToStepBy, TemporalUnit temporalUnit) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| pack-priv Spinner(LocalTime min, LocalTime max, LocalTime initialValue) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| pack-priv Spinner(LocalTime min, LocalTime max, LocalTime initialValue, long amountToStepBy, TemporalUnit temporalUnit) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| public Spinner(ObservableList<T> items) Creates a Spinner instance with the
| |
| Spinner | back to summary |
|---|---|
| public Spinner(SpinnerValueFactory<T> valueFactory) Creates a Spinner instance with the given value factory set.
| |
| cancelEdit | back to summary |
|---|---|
| public final void cancelEdit() If the Spinner is
| |
| commitValue | back to summary |
|---|---|
| public final void commitValue() If the Spinner is
| |
| createDefaultSkin | back to summary |
|---|---|
| protected Skin Overrides javafx. Doc from javafx. Create a new instance of the default skin for this control. This is called to create a skin for the control if
no skin is provided via CSS
| |
| decrement | back to summary |
|---|---|
| public void decrement() Attempts to decrement the
| |
| decrement | back to summary |
|---|---|
| public void decrement(int steps) Attempts to decrement the
| |
| editableProperty | back to summary |
|---|---|
| public final BooleanProperty editableProperty() | |
| editorProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty The editor used by the Spinner control.
| |
| executeAccessibleAction | back to summary |
|---|---|
| public void executeAccessibleAction(AccessibleAction action, Object... parameters) Overrides javafx. Doc from javafx. This method is called by the assistive technology to request the action indicated by the argument should be executed.
This method is commonly overridden by subclasses to implement
action that are required for a specific role.
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getControlCssMetaData | back to summary |
|---|---|
| public List Overrides javafx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getEditor | back to summary |
|---|---|
| public final TextField getEditor() | |
| getInitialDelay | back to summary |
|---|---|
| public final Duration getInitialDelay() | |
| getPromptText | back to summary |
|---|---|
| public final String getPromptText() | |
| getRepeatDelay | back to summary |
|---|---|
| public final Duration getRepeatDelay() | |
| getValue | back to summary |
|---|---|
| public final T getValue() | |
| getValueFactory | back to summary |
|---|---|
| public final SpinnerValueFactory | |
| increment | back to summary |
|---|---|
| public void increment() Attempts to increment the
| |
| increment | back to summary |
|---|---|
| public void increment(int steps) Attempts to increment the
| |
| initialDelayProperty | back to summary |
|---|---|
| public final ObjectProperty The duration that the mouse has to be pressed on an arrow button
before the next value steps. Successive step duration is set using
| |
| isEditable | back to summary |
|---|---|
| public final boolean isEditable() | |
| promptTextProperty | back to summary |
|---|---|
| public final StringProperty promptTextProperty() The prompt text to display in the
| |
| queryAccessibleAttribute | back to summary |
|---|---|
| public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) Overrides javafx. Doc from javafx. This method is called by the assistive technology to request the value for an attribute.
This method is commonly overridden by subclasses to implement
attributes that are required for a specific role.
| |
| repeatDelayProperty | back to summary |
|---|---|
| public final ObjectProperty The duration that the mouse has to be pressed for each successive step
after the first value steps. Initial step duration is set using
| |
| setEditable | back to summary |
|---|---|
| public final void setEditable(boolean value) | |
| setInitialDelay | back to summary |
|---|---|
| public final void setInitialDelay(Duration value) | |
| setPromptText | back to summary |
|---|---|
| public final void setPromptText(String value) | |
| setRepeatDelay | back to summary |
|---|---|
| public final void setRepeatDelay(Duration value) | |
| setText | back to summary |
|---|---|
| private void setText(T value) | |
| setValueFactory | back to summary |
|---|---|
| public final void setValueFactory(SpinnerValueFactory<T> value) | |
| valueFactoryProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| valueProperty | back to summary |
|---|---|
| public final ReadOnlyObjectProperty | |
| wrapValue | back to summary |
|---|---|
| pack-priv static int wrapValue(int value, int min, int max) | |
| wrapValue | back to summary |
|---|---|
| pack-priv static BigDecimal wrapValue(BigDecimal currentValue, BigDecimal newValue, BigDecimal min, BigDecimal max) | |