The three fundamental variables of the slider are min,
max, and value. The value should always
be a number within the range defined by min and
max. min should always be less than or equal to
max (although a slider whose min and
max are equal is a degenerate case that makes no sense).
min defaults to 0, whereas max defaults to 100.
This first example creates a slider whose range, or span, goes from 0 to 1, and whose value defaults to .5:
Slider slider = new Slider(0, 1, 0.5);
This next example shows a slider with customized tick marks and tick mark labels, which also spans from 0 to 1:
Slider slider = new Slider(0, 1, 0.5); slider.setShowTickMarks(true); slider.setShowTickLabels(true); slider.setMajorTickUnit(0.25f); slider.setBlockIncrement(0.1f);
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private DoubleProperty | blockIncrement
The amount by which to adjust the slider if the track of the slider is clicked. |
| private static final String | |
| private static final PseudoClass | |
| private ObjectProperty | labelFormatter
A function for formatting the label for a major tick. |
| private DoubleProperty | majorTickUnit
The unit distance between major tick marks. |
| private DoubleProperty | max
The maximum value represented by this Slider. |
| private DoubleProperty | min
The minimum value represented by this Slider. |
| private IntegerProperty | minorTickCount
The number of minor ticks to place between any two major ticks. |
| private ObjectProperty | orientation
The orientation of the |
| private BooleanProperty | showTickLabels
Indicates that the labels for tick marks should be shown. |
| private BooleanProperty | showTickMarks
Specifies whether the |
| private BooleanProperty | snapToTicks
Indicates whether the |
| private DoubleProperty | value
The current value represented by this Slider. |
| private BooleanProperty | valueChanging
When true, indicates the current value of this Slider is changing. |
| private static final PseudoClass |
| Access | Constructor and Description |
|---|---|
| public | |
| public | Slider(double
Slider minimum value min, double Slider maximum value max, double Slider current value value)Constructs a Slider control with the specified slider min, max and current value values. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void | adjustValues()
Ensures that min is always < max, that value is always somewhere between the two, and that if snapToTicks is set then the value will always be set to align with a tick mark. |
| public final DoubleProperty | |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public void | |
| 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 final double | |
| public static List | Returns: theCssMetaDataHides javafx. Gets the |
| protected List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final StringConverter | |
| public final double | |
| public final double | |
| public final double | |
| public final int | |
| public final Orientation | |
| public final double | |
| public void | |
| private void | |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final ObjectProperty | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final IntegerProperty | |
| public final DoubleProperty | |
| public final ObjectProperty | |
| 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 void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final BooleanProperty | |
| public final BooleanProperty | |
| public final BooleanProperty | |
| private double | snapValueToTicks(double val)
Utility function which, given the specified value, will position it either aligned with a tick, or simply clamp between min & max value, depending on whether snapToTicks is set. |
| public final BooleanProperty | |
| public final DoubleProperty |
| blockIncrement | back to summary |
|---|---|
| private DoubleProperty blockIncrement The amount by which to adjust the slider if the track of the slider is
clicked. This is used when manipulating the slider position using keys. If
| |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS | |
| HORIZONTAL_PSEUDOCLASS_STATE | back to summary |
|---|---|
| private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE | |
| labelFormatter | back to summary |
|---|---|
| private ObjectProperty<StringConverter<Double>> labelFormatter A function for formatting the label for a major tick. The number
representing the major tick will be passed to the function. If this
function is not specified, then a default function will be used by
the | |
| majorTickUnit | back to summary |
|---|---|
| private DoubleProperty majorTickUnit The unit distance between major tick marks. For example, if
the This value should be positive and should be a value less than the span. Out of range values are essentially the same as disabling tick marks. | |
| max | back to summary |
|---|---|
| private DoubleProperty max The maximum value represented by this Slider. This must be a
value greater than | |
| min | back to summary |
|---|---|
| private DoubleProperty min The minimum value represented by this Slider. This must be a
value less than | |
| minorTickCount | back to summary |
|---|---|
| private IntegerProperty minorTickCount The number of minor ticks to place between any two major ticks. This number should be positive or zero. Out of range values will disable disable minor ticks, as will a value of zero. | |
| orientation | back to summary |
|---|---|
| private ObjectProperty<Orientation> orientation The orientation of the | |
| showTickLabels | back to summary |
|---|---|
| private BooleanProperty showTickLabels Indicates that the labels for tick marks should be shown. Typically a
| |
| showTickMarks | back to summary |
|---|---|
| private BooleanProperty showTickMarks Specifies whether the | |
| snapToTicks | back to summary |
|---|---|
| private BooleanProperty snapToTicks Indicates whether the | |
| value | back to summary |
|---|---|
| private DoubleProperty value The current value represented by this Slider. This value must
always be between | |
| valueChanging | back to summary |
|---|---|
| private BooleanProperty valueChanging When true, indicates the current value of this Slider is changing. It provides notification that the value is changing. Once the value is computed, it is reset back to false. | |
| VERTICAL_PSEUDOCLASS_STATE | back to summary |
|---|---|
| private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE | |
| Slider | back to summary |
|---|---|
| public Slider() Creates a default Slider instance. | |
| Slider | back to summary |
|---|---|
| public Slider(double min, double max, double value) Constructs a Slider control with the specified slider min, max and current value values.
| |
| adjustValue | back to summary |
|---|---|
| public void adjustValue(double newValue) Adjusts Note This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly.
| |
| adjustValues | back to summary |
|---|---|
| private void adjustValues() Ensures that min is always < max, that value is always somewhere between the two, and that if snapToTicks is set then the value will always be set to align with a tick mark. | |
| blockIncrementProperty | back to summary |
|---|---|
| public final DoubleProperty blockIncrementProperty() | |
| 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() Decrements the value by | |
| 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.
| |
| getBlockIncrement | back to summary |
|---|---|
| public final double getBlockIncrement() | |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Gets the
| |
| getControlCssMetaData | back to summary |
|---|---|
| protected List Overrides javafx. Doc from javafx. Gets the unmodifiable list of the control's CSS-styleable properties.
| |
| getLabelFormatter | back to summary |
|---|---|
| public final StringConverter | |
| getMajorTickUnit | back to summary |
|---|---|
| public final double getMajorTickUnit() | |
| getMax | back to summary |
|---|---|
| public final double getMax() | |
| getMin | back to summary |
|---|---|
| public final double getMin() | |
| getMinorTickCount | back to summary |
|---|---|
| public final int getMinorTickCount() | |
| getOrientation | back to summary |
|---|---|
| public final Orientation getOrientation() | |
| getValue | back to summary |
|---|---|
| public final double getValue() | |
| increment | back to summary |
|---|---|
| public void increment() Increments the value by | |
| initialize | back to summary |
|---|---|
| private void initialize() | |
| isShowTickLabels | back to summary |
|---|---|
| public final boolean isShowTickLabels() | |
| isShowTickMarks | back to summary |
|---|---|
| public final boolean isShowTickMarks() | |
| isSnapToTicks | back to summary |
|---|---|
| public final boolean isSnapToTicks() | |
| isValueChanging | back to summary |
|---|---|
| public final boolean isValueChanging() | |
| labelFormatterProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| majorTickUnitProperty | back to summary |
|---|---|
| public final DoubleProperty majorTickUnitProperty() | |
| maxProperty | back to summary |
|---|---|
| public final DoubleProperty maxProperty() | |
| minorTickCountProperty | back to summary |
|---|---|
| public final IntegerProperty minorTickCountProperty() | |
| minProperty | back to summary |
|---|---|
| public final DoubleProperty minProperty() | |
| orientationProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| 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.
| |
| setBlockIncrement | back to summary |
|---|---|
| public final void setBlockIncrement(double value) | |
| setLabelFormatter | back to summary |
|---|---|
| public final void setLabelFormatter(StringConverter<Double> value) | |
| setMajorTickUnit | back to summary |
|---|---|
| public final void setMajorTickUnit(double value) | |
| setMax | back to summary |
|---|---|
| public final void setMax(double value) | |
| setMin | back to summary |
|---|---|
| public final void setMin(double value) | |
| setMinorTickCount | back to summary |
|---|---|
| public final void setMinorTickCount(int value) | |
| setOrientation | back to summary |
|---|---|
| public final void setOrientation(Orientation value) | |
| setShowTickLabels | back to summary |
|---|---|
| public final void setShowTickLabels(boolean value) | |
| setShowTickMarks | back to summary |
|---|---|
| public final void setShowTickMarks(boolean value) | |
| setSnapToTicks | back to summary |
|---|---|
| public final void setSnapToTicks(boolean value) | |
| setValue | back to summary |
|---|---|
| public final void setValue(double value) | |
| setValueChanging | back to summary |
|---|---|
| public final void setValueChanging(boolean value) | |
| showTickLabelsProperty | back to summary |
|---|---|
| public final BooleanProperty showTickLabelsProperty() | |
| showTickMarksProperty | back to summary |
|---|---|
| public final BooleanProperty showTickMarksProperty() | |
| snapToTicksProperty | back to summary |
|---|---|
| public final BooleanProperty snapToTicksProperty() | |
| snapValueToTicks | back to summary |
|---|---|
| private double snapValueToTicks(double val) Utility function which, given the specified value, will position it either aligned with a tick, or simply clamp between min & max value, depending on whether snapToTicks is set. Note This function is intended to be used by experts, primarily by those implementing new Skins or Behaviors. It is not common for developers or designers to access this function directly. | |
| valueChangingProperty | back to summary |
|---|---|
| public final BooleanProperty valueChangingProperty() | |
| valueProperty | back to summary |
|---|---|
| public final DoubleProperty valueProperty() | |
| Modifier and Type | Field and Description |
|---|---|
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final CssMetaData | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| private |
| BLOCK_INCREMENT | back to summary |
|---|---|
| private static final CssMetaData<Slider, Number> BLOCK_INCREMENT | |
| MAJOR_TICK_UNIT | back to summary |
|---|---|
| private static final CssMetaData<Slider, Number> MAJOR_TICK_UNIT | |
| MINOR_TICK_COUNT | back to summary |
|---|---|
| private static final CssMetaData<Slider, Number> MINOR_TICK_COUNT | |
| ORIENTATION | back to summary |
|---|---|
| private static final CssMetaData<Slider, Orientation> ORIENTATION | |
| SHOW_TICK_LABELS | back to summary |
|---|---|
| private static final CssMetaData<Slider, Boolean> SHOW_TICK_LABELS | |
| SHOW_TICK_MARKS | back to summary |
|---|---|
| private static final CssMetaData<Slider, Boolean> SHOW_TICK_MARKS | |
| SNAP_TO_TICKS | back to summary |
|---|---|
| private static final CssMetaData<Slider, Boolean> SNAP_TO_TICKS | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |