Spec-Zone .ru
спецификации, руководства, описания, API
|
public class Slider extends Control
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 who's 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 who's range, or span, goes from 0 to 1, and who's value defaults to .5:
import javafx.scene.control.Slider; 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:
import javafx.scene.control.Slider; Slider slider = new Slider(0, 1, 0.5); slider.setShowTickMarks(true); slider.setShowTickLabels(true); slider.setMajorTickUnit(0.25f); slider.setBlockIncrement(0.1f);
Type | Property and Description |
---|---|
DoubleProperty |
blockIncrement
The amount by which to adjust the slider if the track of the slider is
clicked.
|
ObjectProperty<StringConverter<java.lang.Double>> |
labelFormatter
A function for formatting the label for a major tick.
|
DoubleProperty |
majorTickUnit
The unit distance between major tick marks.
|
DoubleProperty |
max
The maximum value represented by this Slider.
|
IntegerProperty |
minorTickCount
The number of minor ticks to place between any two major ticks.
|
DoubleProperty |
min
The minimum value represented by this Slider.
|
ObjectProperty<Orientation> |
orientation
The orientation of the
Slider can either be horizontal
or vertical. |
BooleanProperty |
showTickLabels
Indicates that the labels for tick marks should be shown.
|
BooleanProperty |
showTickMarks
Specifies whether the
Skin implementation should show tick marks. |
BooleanProperty |
snapToTicks
Indicates whether the
value of the Slider should always
be aligned with the tick marks. |
BooleanProperty |
valueChanging
When true, indicates the current value of this Slider is changing.
|
DoubleProperty |
value
The current value represented by this Slider.
|
contextMenuProperty, heightProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, prefHeightProperty, prefWidthProperty, skinProperty, tooltipProperty, widthProperty
needsLayoutProperty
blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, managedProperty, mouseTransparentProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDraggedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onScrollProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
USE_COMPUTED_SIZE, USE_PREF_SIZE
Constructor and Description |
---|
Slider() |
Slider(double min,
double max,
double value)
Constructs a Slider control with the specified slider min, max and current value values.
|
Modifier and Type | Method and Description |
---|---|
void |
adjustValue(double newValue)
Adjusts
value to match newValue . |
DoubleProperty |
blockIncrementProperty()
The amount by which to adjust the slider if the track of the slider is
clicked.
|
void |
decrement()
Decrements the value by
blockIncrement , bounded by max. |
double |
getBlockIncrement()
The amount by which to adjust the slider if the track of the slider is
clicked.
|
StringConverter<java.lang.Double> |
getLabelFormatter()
A function for formatting the label for a major tick.
|
double |
getMajorTickUnit()
The unit distance between major tick marks.
|
double |
getMax()
The maximum value represented by this Slider.
|
double |
getMin()
The minimum value represented by this Slider.
|
int |
getMinorTickCount()
The number of minor ticks to place between any two major ticks.
|
Orientation |
getOrientation()
The orientation of the
Slider can either be horizontal
or vertical. |
double |
getValue()
The current value represented by this Slider.
|
void |
increment()
Increments the value by
blockIncrement , bounded by max. |
boolean |
isShowTickLabels()
Indicates that the labels for tick marks should be shown.
|
boolean |
isShowTickMarks()
Specifies whether the
Skin implementation should show tick marks. |
boolean |
isSnapToTicks()
Indicates whether the
value of the Slider should always
be aligned with the tick marks. |
boolean |
isValueChanging()
When true, indicates the current value of this Slider is changing.
|
ObjectProperty<StringConverter<java.lang.Double>> |
labelFormatterProperty()
A function for formatting the label for a major tick.
|
DoubleProperty |
majorTickUnitProperty()
The unit distance between major tick marks.
|
DoubleProperty |
maxProperty()
The maximum value represented by this Slider.
|
IntegerProperty |
minorTickCountProperty()
The number of minor ticks to place between any two major ticks.
|
DoubleProperty |
minProperty()
The minimum value represented by this Slider.
|
ObjectProperty<Orientation> |
orientationProperty()
The orientation of the
Slider can either be horizontal
or vertical. |
void |
setBlockIncrement(double value)
The amount by which to adjust the slider if the track of the slider is
clicked.
|
void |
setLabelFormatter(StringConverter<java.lang.Double> value)
A function for formatting the label for a major tick.
|
void |
setMajorTickUnit(double value)
The unit distance between major tick marks.
|
void |
setMax(double value)
The maximum value represented by this Slider.
|
void |
setMin(double value)
The minimum value represented by this Slider.
|
void |
setMinorTickCount(int value)
The number of minor ticks to place between any two major ticks.
|
void |
setOrientation(Orientation value)
The orientation of the
Slider can either be horizontal
or vertical. |
void |
setShowTickLabels(boolean value)
Indicates that the labels for tick marks should be shown.
|
void |
setShowTickMarks(boolean value)
Specifies whether the
Skin implementation should show tick marks. |
void |
setSnapToTicks(boolean value)
Indicates whether the
value of the Slider should always
be aligned with the tick marks. |
void |
setValue(double value)
The current value represented by this Slider.
|
void |
setValueChanging(boolean value)
When true, indicates the current value of this Slider is changing.
|
BooleanProperty |
showTickLabelsProperty()
Indicates that the labels for tick marks should be shown.
|
BooleanProperty |
showTickMarksProperty()
Specifies whether the
Skin implementation should show tick marks. |
BooleanProperty |
snapToTicksProperty()
Indicates whether the
value of the Slider should always
be aligned with the tick marks. |
BooleanProperty |
valueChangingProperty()
When true, indicates the current value of this Slider is changing.
|
DoubleProperty |
valueProperty()
The current value represented by this Slider.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, getBaselineOffset, getContextMenu, getHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getPrefHeight, getPrefWidth, getSkin, getTooltip, getUserAgentStylesheet, getWidth, heightProperty, intersects, isResizable, layoutChildren, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, setContextMenu, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setPrefHeight, setPrefSize, setPrefWidth, setSkin, setTooltip, setWidth, skinProperty, tooltipProperty, widthProperty
getChildren, getChildrenUnmodifiable, getManagedChildren, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, setNeedsLayout
addEventFilter, addEventHandler, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragged, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnScroll, getOpacity, getParent, getProperties, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToScene, localToScene, localToScene, lookupAll, managedProperty, mouseTransparentProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDraggedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onScrollProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragged, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnScroll, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, startDragAndDrop, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, visibleProperty
min
.getMax()
,
setMax(double)
max
.getMin()
,
setMin(double)
min
and max
,
inclusive. If it is ever out of bounds either due to min
or
max
changing or due to itself being changed, then it will
be clamped to always remain valid.getValue()
,
setValue(double)
isValueChanging()
,
setValueChanging(boolean)
Slider
can either be horizontal
or vertical.getOrientation()
,
setOrientation(Orientation)
Skin
implementation will only show labels if
showTickMarks
is also true.isShowTickLabels()
,
setShowTickLabels(boolean)
Skin
implementation should show tick marks.isShowTickMarks()
,
setShowTickMarks(boolean)
min
is 0 and the max
is 100 and the
majorTickUnit
is 25, then there would be 5 tick marks: one at
position 0, one at position 25, one at position 50, one at position
75, and a final one at position 100.
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.
getMajorTickUnit()
,
setMajorTickUnit(double)
getMinorTickCount()
,
setMinorTickCount(int)
value
of the Slider
should always
be aligned with the tick marks. This is honored even if the tick marks
are not shown.isSnapToTicks()
,
setSnapToTicks(boolean)
Skin
implementation.snapToTicks
is true then the nearest tick mark to the adjusted
value will be used.getBlockIncrement()
,
setBlockIncrement(double)
public Slider()
public Slider(double min, double max, double value)
min
- Slider minimum valuemax
- Slider maximum valuevalue
- Slider current valuepublic final void setMax(double value)
min
.public final double getMax()
min
.public final DoubleProperty maxProperty()
min
.getMax()
,
setMax(double)
public final void setMin(double value)
max
.public final double getMin()
max
.public final DoubleProperty minProperty()
max
.getMin()
,
setMin(double)
public final void setValue(double value)
public final double getValue()
public final DoubleProperty valueProperty()
min
and max
,
inclusive. If it is ever out of bounds either due to min
or
max
changing or due to itself being changed, then it will
be clamped to always remain valid.getValue()
,
setValue(double)
public final void setValueChanging(boolean value)
public final boolean isValueChanging()
public final BooleanProperty valueChangingProperty()
isValueChanging()
,
setValueChanging(boolean)
public final void setOrientation(Orientation value)
Slider
can either be horizontal
or vertical.public final Orientation getOrientation()
Slider
can either be horizontal
or vertical.public final ObjectProperty<Orientation> orientationProperty()
Slider
can either be horizontal
or vertical.getOrientation()
,
setOrientation(Orientation)
public final void setShowTickLabels(boolean value)
Skin
implementation will only show labels if
showTickMarks
is also true.public final boolean isShowTickLabels()
Skin
implementation will only show labels if
showTickMarks
is also true.public final BooleanProperty showTickLabelsProperty()
Skin
implementation will only show labels if
showTickMarks
is also true.isShowTickLabels()
,
setShowTickLabels(boolean)
public final void setShowTickMarks(boolean value)
Skin
implementation should show tick marks.public final boolean isShowTickMarks()
Skin
implementation should show tick marks.public final BooleanProperty showTickMarksProperty()
Skin
implementation should show tick marks.isShowTickMarks()
,
setShowTickMarks(boolean)
public final void setMajorTickUnit(double value)
min
is 0 and the max
is 100 and the
majorTickUnit
is 25, then there would be 5 tick marks: one at
position 0, one at position 25, one at position 50, one at position
75, and a final one at position 100.
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.
public final double getMajorTickUnit()
min
is 0 and the max
is 100 and the
majorTickUnit
is 25, then there would be 5 tick marks: one at
position 0, one at position 25, one at position 50, one at position
75, and a final one at position 100.
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.
public final DoubleProperty majorTickUnitProperty()
min
is 0 and the max
is 100 and the
majorTickUnit
is 25, then there would be 5 tick marks: one at
position 0, one at position 25, one at position 50, one at position
75, and a final one at position 100.
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.
getMajorTickUnit()
,
setMajorTickUnit(double)
public final void setMinorTickCount(int value)
public final int getMinorTickCount()
public final IntegerProperty minorTickCountProperty()
getMinorTickCount()
,
setMinorTickCount(int)
public final void setSnapToTicks(boolean value)
value
of the Slider
should always
be aligned with the tick marks. This is honored even if the tick marks
are not shown.public final boolean isSnapToTicks()
value
of the Slider
should always
be aligned with the tick marks. This is honored even if the tick marks
are not shown.public final BooleanProperty snapToTicksProperty()
value
of the Slider
should always
be aligned with the tick marks. This is honored even if the tick marks
are not shown.isSnapToTicks()
,
setSnapToTicks(boolean)
public final void setLabelFormatter(StringConverter<java.lang.Double> value)
Skin
implementation.public final StringConverter<java.lang.Double> getLabelFormatter()
Skin
implementation.public final ObjectProperty<StringConverter<java.lang.Double>> labelFormatterProperty()
Skin
implementation.public final void setBlockIncrement(double value)
snapToTicks
is true then the nearest tick mark to the adjusted
value will be used.public final double getBlockIncrement()
snapToTicks
is true then the nearest tick mark to the adjusted
value will be used.public final DoubleProperty blockIncrementProperty()
snapToTicks
is true then the nearest tick mark to the adjusted
value will be used.getBlockIncrement()
,
setBlockIncrement(double)
public void adjustValue(double newValue)
value
to match newValue
. The
value
is the actual amount between the
min
and max
. This function
also takes into account snapToTicks
, which
is the main difference between adjustValue and setValue. It also ensures
that the value is some valid number between min and max.public void increment()
blockIncrement
, bounded by max. If the
max is less than or equal to the min, then this method does nothing.public void decrement()
blockIncrement
, bounded by max. If the
max is less than or equal to the min, then this method does nothing.Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to