Slider control with support
for two 'thumbs', rather than one. A thumb is the non-technical name for the
draggable area inside the Slider / RangeSlider that allows for a value to be
set.
Because the RangeSlider has two thumbs, it also has a few additional rules and user interactions:
Slider control only has one
value property, the RangeSlider has a
low value and a
high value property, not surprisingly
represented by the 'low value' and 'high value' thumbs.
orientation, there are two screenshots below:
| Horizontal: | ![]() |
| Vertical: | ![]() |
orientation property.
Once the orientation is determined, the next most important decision is
to determine what the min / max
and default low / high
values are. The min / max values represent the smallest and largest legal
values for the thumbs to be set to, whereas the low / high values represent
where the thumbs are currently, within the bounds of the min / max values.
Because all four values are required in all circumstances, they are all
required parameters to instantiate a RangeSlider: the constructor takes
four doubles, representing min, max, lowValue and highValue (in that order).
For example, here is a simple horizontal RangeSlider that has a minimum value of 0, a maximum value of 100, a low value of 10 and a high value of 90:
final RangeSlider hSlider = new RangeSlider(0, 100, 10, 90);
To configure the hSlider to look like the RangeSlider in the horizontal RangeSlider screenshot above only requires a few additional properties to be set:
final RangeSlider hSlider = new RangeSlider(0, 100, 10, 90);
hSlider.setShowTickMarks(true);
hSlider.setShowTickLabels(true);
hSlider.setBlockIncrement(10);
To create a vertical slider, simply do the following:
final RangeSlider vSlider = new RangeSlider(0, 200, 30, 150);
vSlider.setOrientation(Orientation.VERTICAL);
This code creates a RangeSlider with a min value of 0, a max value of 200, a low value of 30, and a high value of 150.
Slider
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private DoubleProperty | |
| private static final String | DEFAULT_STYLE_CLASS
* Stylesheet Handling * * |
| private DoubleProperty | |
| private BooleanProperty | |
| private static final PseudoClass | |
| private DoubleProperty | |
| private BooleanProperty | |
| private DoubleProperty | |
| private DoubleProperty | max
* Properties copied from Slider (and slightly edited) * * |
| private DoubleProperty | |
| private IntegerProperty | |
| private ObjectProperty | |
| private BooleanProperty | |
| private BooleanProperty | |
| private BooleanProperty | |
| private final ObjectProperty | |
| private static final PseudoClass |
| Access | Constructor and Description |
|---|---|
| public | RangeSlider()
Creates a new RangeSlider instance using default values of 0.0, 0.25, 0.75 and 1.0 for min/lowValue/highValue/max, respectively. |
| public | RangeSlider(double
The minimum allowable value that the RangeSlider will allow. min, double The maximum allowable value that the RangeSlider will allow. max, double The initial value for the low value in the RangeSlider. lowValue, double The initial value for the high value in the RangeSlider. highValue)Instantiates a default, horizontal RangeSlider with the specified min/max/low/high values. |
| Modifier and Type | Method and Description |
|---|---|
| public void | adjustHighValue(double newValue)
Adjusts |
| private void | |
| public void | adjustLowValue(double newValue)
Adjusts |
| private 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 | Returns: A DoublePropertyThe amount by which to adjust the slider if the track of the slider is clicked. |
| protected Skin | createDefaultSkin()
Overrides javafx. Create a new instance of the default skin for this control. |
| public void | |
| public void | |
| public final double | getBlockIncrement()
Returns: The amount by which to adjust the slider if the track of the slider is clicked. |
| public static List | Returns: The CssMetaData associated with this class, which may include the CssMetaData of its super classes.Hides javafx. Gets the |
| public List | getControlCssMetaData()
Overrides javafx. Gets the unmodifiable list of the control's CSS-styleable properties. |
| public final double | |
| public final StringConverter | Returns: the value of the property tickLabelFormatter.Gets the value of the property tickLabelFormatter. |
| public final double | |
| public final double | |
| public final double | |
| public final double | |
| public final int | |
| public final Orientation | |
| public String | getUserAgentStylesheet()
Overrides javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. |
| public final BooleanProperty | highValueChangingProperty()
When true, indicates the current high value of this RangeSlider is changing. |
| public final DoubleProperty | highValueProperty()
The high value property represents the current position of the high value
thumb, and is within the allowable range as specified by the
|
| public void | |
| public void | |
| public final boolean | isHighValueChanging()
Returns whether or not the high value of this RangeSlider is currently changing. |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final boolean | |
| public final ObjectProperty | Returns: a Property containing the StringConverter.StringConverter used to format tick mark labels. |
| public final BooleanProperty | lowValueChangingProperty()
When true, indicates the current low value of this RangeSlider is changing. |
| public final DoubleProperty | lowValueProperty()
The low value property represents the current position of the low value
thumb, and is within the allowable range as specified by the
|
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final IntegerProperty | Returns: An InterPropertyThe number of minor ticks to place between any two major ticks. |
| public final DoubleProperty | |
| public final ObjectProperty | Returns: An Objectproperty representing the orientation of the Slider.The orientation of the |
| public final void | setBlockIncrement(double value)
Sets the amount by which to adjust the slider if the track of the slider is clicked. |
| public final void | setHighValue(double d)
Sets the high value for the range slider, which may or may not be clamped
to be within the allowable range as specified by the
|
| public final void | setHighValueChanging(boolean
True if the high value is changing, false otherwise. value)Call this when high low value is changing. |
| public final void | |
| public final void | setLowValue(double d)
Sets the low value for the range slider, which may or may not be clamped
to be within the allowable range as specified by the
|
| public final void | setLowValueChanging(boolean
True if the low value is changing, false otherwise. value)Call this when the low value is changing. |
| 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 | Returns: A BooleanPropertyIndicates that the labels for tick marks should be shown. |
| public final BooleanProperty | showTickMarksProperty()
Returns: A BooleanProperty that specifies whether the |
| public final BooleanProperty | Returns: A BooleanProperty.Indicates whether the |
| private double |
| blockIncrement | back to summary |
|---|---|
| private DoubleProperty blockIncrement | |
| DEFAULT_STYLE_CLASS | back to summary |
|---|---|
| private static final String DEFAULT_STYLE_CLASS * Stylesheet Handling * * | |
| highValue | back to summary |
|---|---|
| private DoubleProperty highValue | |
| highValueChanging | back to summary |
|---|---|
| private BooleanProperty highValueChanging | |
| HORIZONTAL_PSEUDOCLASS_STATE | back to summary |
|---|---|
| private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE | |
| lowValue | back to summary |
|---|---|
| private DoubleProperty lowValue | |
| lowValueChanging | back to summary |
|---|---|
| private BooleanProperty lowValueChanging | |
| majorTickUnit | back to summary |
|---|---|
| private DoubleProperty majorTickUnit | |
| max | back to summary |
|---|---|
| private DoubleProperty max * Properties copied from Slider (and slightly edited) * * | |
| min | back to summary |
|---|---|
| private DoubleProperty min | |
| minorTickCount | back to summary |
|---|---|
| private IntegerProperty minorTickCount | |
| orientation | back to summary |
|---|---|
| private ObjectProperty<Orientation> orientation | |
| showTickLabels | back to summary |
|---|---|
| private BooleanProperty showTickLabels | |
| showTickMarks | back to summary |
|---|---|
| private BooleanProperty showTickMarks | |
| snapToTicks | back to summary |
|---|---|
| private BooleanProperty snapToTicks | |
| tickLabelFormatter | back to summary |
|---|---|
| private final ObjectProperty<StringConverter<Number>> tickLabelFormatter | |
| VERTICAL_PSEUDOCLASS_STATE | back to summary |
|---|---|
| private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE | |
| RangeSlider | back to summary |
|---|---|
| public RangeSlider() Creates a new RangeSlider instance using default values of 0.0, 0.25, 0.75 and 1.0 for min/lowValue/highValue/max, respectively. | |
| RangeSlider | back to summary |
|---|---|
| public RangeSlider(double min, double max, double lowValue, double highValue) Instantiates a default, horizontal RangeSlider with the specified min/max/low/high values.
| |
| adjustHighValue | back to summary |
|---|---|
| public void adjustHighValue(double newValue) Adjusts | |
| adjustHighValues | back to summary |
|---|---|
| private void adjustHighValues() | |
| adjustLowValue | back to summary |
|---|---|
| public void adjustLowValue(double newValue) Adjusts | |
| adjustLowValues | back to summary |
|---|---|
| private void adjustLowValues() | |
| 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() 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
| |
| 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
| |
| decrementHighValue | back to summary |
|---|---|
| public void decrementHighValue() Decrements the | |
| decrementLowValue | back to summary |
|---|---|
| public void decrementLowValue() Decrements the | |
| getBlockIncrement | back to summary |
|---|---|
public final double getBlockIncrement()
| |
| getClassCssMetaData | back to summary |
|---|---|
| public static List Hides javafx. Doc from 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.
| |
| getHighValue | back to summary |
|---|---|
| public final double getHighValue() Returns the current high value for the range slider. | |
| getLabelFormatter | back to summary |
|---|---|
| public final StringConverter Gets the value of the property tickLabelFormatter.
| |
| getLowValue | back to summary |
|---|---|
| public final double getLowValue() Returns the current low value for the range slider. | |
| 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()
| |
| getUserAgentStylesheet | back to summary |
|---|---|
| public String getUserAgentStylesheet() Overrides javafx. Doc from javafx. An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls. The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath. Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.
For additional information about using CSS with the scene graph,
see the CSS Reference Guide.
| |
| highValueChangingProperty | back to summary |
|---|---|
| public final BooleanProperty highValueChangingProperty() When true, indicates the current high value of this RangeSlider is changing. It provides notification that the high value is changing. Once the high value is computed, it is set back to false. | |
| highValueProperty | back to summary |
|---|---|
| public final DoubleProperty highValueProperty() The high value property represents the current position of the high value
thumb, and is within the allowable range as specified by the
| |
| incrementHighValue | back to summary |
|---|---|
| public void incrementHighValue() Increments the | |
| incrementLowValue | back to summary |
|---|---|
| public void incrementLowValue() Increments the | |
| isHighValueChanging | back to summary |
|---|---|
| public final boolean isHighValueChanging() Returns whether or not the high value of this RangeSlider is currently changing. | |
| isLowValueChanging | back to summary |
|---|---|
| public final boolean isLowValueChanging() Returns whether or not the low value of this RangeSlider is currently changing. | |
| isShowTickLabels | back to summary |
|---|---|
public final boolean isShowTickLabels()
| |
| isShowTickMarks | back to summary |
|---|---|
public final boolean isShowTickMarks()
| |
| isSnapToTicks | back to summary |
|---|---|
public final boolean isSnapToTicks()
| |
| labelFormatterProperty | back to summary |
|---|---|
| public final ObjectProperty StringConverter used to format tick mark labels. If null a default will be used.
| |
| lowValueChangingProperty | back to summary |
|---|---|
| public final BooleanProperty lowValueChangingProperty() When true, indicates the current low value of this RangeSlider is changing. It provides notification that the low value is changing. Once the low value is computed, it is set back to false. | |
| lowValueProperty | back to summary |
|---|---|
| public final DoubleProperty lowValueProperty() The low value property represents the current position of the low value
thumb, and is within the allowable range as specified by the
| |
| majorTickUnitProperty | back to summary |
|---|---|
| public final DoubleProperty majorTickUnitProperty() 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.
| |
| maxProperty | back to summary |
|---|---|
public final DoubleProperty maxProperty()
| |
| minorTickCountProperty | back to summary |
|---|---|
| public final IntegerProperty minorTickCountProperty() 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.
| |
| minProperty | back to summary |
|---|---|
public final DoubleProperty minProperty()
| |
| orientationProperty | back to summary |
|---|---|
| public final ObjectProperty The orientation of the
| |
| setBlockIncrement | back to summary |
|---|---|
| public final void setBlockIncrement(double value) Sets the amount by which to adjust the slider if the track of the slider is clicked.
| |
| setHighValue | back to summary |
|---|---|
| public final void setHighValue(double d) Sets the high value for the range slider, which may or may not be clamped
to be within the allowable range as specified by the
| |
| setHighValueChanging | back to summary |
|---|---|
| public final void setHighValueChanging(boolean value) Call this when high low value is changing.
| |
| setLabelFormatter | back to summary |
|---|---|
| public final void setLabelFormatter(StringConverter<Number> value) Sets the value of the property tickLabelFormatter. | |
| setLowValue | back to summary |
|---|---|
| public final void setLowValue(double d) Sets the low value for the range slider, which may or may not be clamped
to be within the allowable range as specified by the
| |
| setLowValueChanging | back to summary |
|---|---|
| public final void setLowValueChanging(boolean value) Call this when the low value is changing.
| |
| setMajorTickUnit | back to summary |
|---|---|
| public final void setMajorTickUnit(double value) Sets the unit distance between major tick marks.
| |
| setMax | back to summary |
|---|---|
| public final void setMax(double value) Sets the maximum value for this Slider. | |
| setMin | back to summary |
|---|---|
| public final void setMin(double value) Sets the minimum value for this Slider. | |
| setMinorTickCount | back to summary |
|---|---|
| public final void setMinorTickCount(int value) Sets the number of minor ticks to place between any two major ticks.
| |
| setOrientation | back to summary |
|---|---|
| public final void setOrientation(Orientation value) Sets the orientation of the Slider. | |
| setShowTickLabels | back to summary |
|---|---|
| public final void setShowTickLabels(boolean value) Sets whether labels of tick marks should be shown or not. | |
| setShowTickMarks | back to summary |
|---|---|
| public final void setShowTickMarks(boolean value) Specifies whether the | |
| setSnapToTicks | back to summary |
|---|---|
| public final void setSnapToTicks(boolean value) Sets the value of SnapToTicks.
| |
| showTickLabelsProperty | back to summary |
|---|---|
| public final BooleanProperty showTickLabelsProperty() Indicates that the labels for tick marks should be shown. Typically a
| |
| showTickMarksProperty | back to summary |
|---|---|
public final BooleanProperty showTickMarksProperty()
| |
| snapToTicksProperty | back to summary |
|---|---|
| public final BooleanProperty snapToTicksProperty() Indicates whether the
| |
| snapValueToTicks | back to summary |
|---|---|
| private double snapValueToTicks(double d) | |
| 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<RangeSlider, Number> BLOCK_INCREMENT | |
| MAJOR_TICK_UNIT | back to summary |
|---|---|
| private static final CssMetaData<RangeSlider, Number> MAJOR_TICK_UNIT | |
| MINOR_TICK_COUNT | back to summary |
|---|---|
| private static final CssMetaData<RangeSlider, Number> MINOR_TICK_COUNT | |
| ORIENTATION | back to summary |
|---|---|
| private static final CssMetaData<RangeSlider, Orientation> ORIENTATION | |
| SHOW_TICK_LABELS | back to summary |
|---|---|
| private static final CssMetaData<RangeSlider, Boolean> SHOW_TICK_LABELS | |
| SHOW_TICK_MARKS | back to summary |
|---|---|
| private static final CssMetaData<RangeSlider, Boolean> SHOW_TICK_MARKS | |
| SNAP_TO_TICKS | back to summary |
|---|---|
| private static final CssMetaData<RangeSlider, Boolean> SNAP_TO_TICKS | |
| STYLEABLES | back to summary |
|---|---|
| private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES | |
| StyleableProperties | back to summary |
|---|---|
| private StyleableProperties() | |