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.
|
contextMenu, height, maxHeight, maxWidth, minHeight, minWidth, prefHeight, prefWidth, skinClassName, skin, tooltip, width
needsLayout
blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
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()
Gets the value of the property blockIncrement.
|
StringConverter<java.lang.Double> |
getLabelFormatter()
Gets the value of the property labelFormatter.
|
double |
getMajorTickUnit()
Gets the value of the property majorTickUnit.
|
double |
getMax()
Gets the value of the property max.
|
double |
getMin()
Gets the value of the property min.
|
int |
getMinorTickCount()
Gets the value of the property minorTickCount.
|
Orientation |
getOrientation()
Gets the value of the property orientation.
|
double |
getValue()
Gets the value of the property value.
|
void |
increment()
Increments the value by
blockIncrement , bounded by max. |
boolean |
isShowTickLabels()
Gets the value of the property showTickLabels.
|
boolean |
isShowTickMarks()
Gets the value of the property showTickMarks.
|
boolean |
isSnapToTicks()
Gets the value of the property snapToTicks.
|
boolean |
isValueChanging()
Gets the value of the property valueChanging.
|
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)
Sets the value of the property blockIncrement.
|
void |
setLabelFormatter(StringConverter<java.lang.Double> value)
Sets the value of the property labelFormatter.
|
void |
setMajorTickUnit(double value)
Sets the value of the property majorTickUnit.
|
void |
setMax(double value)
Sets the value of the property max.
|
void |
setMin(double value)
Sets the value of the property min.
|
void |
setMinorTickCount(int value)
Sets the value of the property minorTickCount.
|
void |
setOrientation(Orientation value)
Sets the value of the property orientation.
|
void |
setShowTickLabels(boolean value)
Sets the value of the property showTickLabels.
|
void |
setShowTickMarks(boolean value)
Sets the value of the property showTickMarks.
|
void |
setSnapToTicks(boolean value)
Sets the value of the property snapToTicks.
|
void |
setValue(double value)
Sets the value of the property value.
|
void |
setValueChanging(boolean value)
Sets the value of the property valueChanging.
|
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, setSkinClassName, setTooltip, setWidth, skinClassNameProperty, skinProperty, tooltipProperty, widthProperty
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, 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, getLocalToParentTransform, getLocalToSceneTransform, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, 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, localToParentTransformProperty, localToScene, localToScene, localToScene, localToSceneTransformProperty, lookupAll, managedProperty, mouseTransparentProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, 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, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, visibleProperty
public final DoubleProperty maxProperty
min
.getMax()
,
setMax(double)
public final DoubleProperty minProperty
max
.getMin()
,
setMin(double)
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 BooleanProperty valueChangingProperty
isValueChanging()
,
setValueChanging(boolean)
public final ObjectProperty<Orientation> orientationProperty
Slider
can either be horizontal
or vertical.getOrientation()
,
setOrientation(Orientation)
public final BooleanProperty showTickLabelsProperty
Skin
implementation will only show labels if
showTickMarks
is also true.isShowTickLabels()
,
setShowTickLabels(boolean)
public final BooleanProperty showTickMarksProperty
Skin
implementation should show tick marks.isShowTickMarks()
,
setShowTickMarks(boolean)
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 IntegerProperty minorTickCountProperty
getMinorTickCount()
,
setMinorTickCount(int)
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 ObjectProperty<StringConverter<java.lang.Double>> labelFormatterProperty
Skin
implementation.public final DoubleProperty blockIncrementProperty
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, 2012, Oracle and/or its affiliates. All rights reserved. Use is subject to