Top Description Inners Fields Constructors Methods
javafx.scene.control

public Class ScrollBar

extends Control
Class Inheritance
Known Direct Subclasses
com.sun.javafx.scene.control.VirtualScrollBar
Imports
com.sun.javafx.scene.control.Properties, com.sun.javafx.util.Utils, javafx.css.converter.EnumConverter, .SizeConverter, javafx.scene.control.skin.ScrollBarSkin, javafx.beans.property.DoubleProperty, .ObjectProperty, .SimpleDoubleProperty, javafx.beans.value.WritableValue, javafx.css.CssMetaData, .PseudoClass, .Styleable, .StyleableDoubleProperty, .StyleableObjectProperty, .StyleableProperty, javafx.geometry.Orientation, javafx.scene.AccessibleAction, .AccessibleAttribute, .AccessibleRole, java.util.ArrayList, .Collections, .List

Either a horizontal or vertical bar with increment and decrement buttons and a "thumb" with which the user can interact. Typically not used alone but used for building up more complicated controls such as the ScrollPane and ListView.

ScrollBar sets focusTraversable to false.

This example creates a vertical ScrollBar:

 ScrollBar s1 = new ScrollBar();
s1.setOrientation(Orientation.VERTICAL);
Image of the ScrollBar control
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private DoubleProperty
blockIncrement

The amount by which to adjust the scrollbar if the track of the bar is clicked.

private static final String
DEFAULT_STYLE_CLASS

Initialize the style class to 'scroll-bar'.

private static final PseudoClass
HORIZONTAL_PSEUDOCLASS_STATE

Pseudo-class indicating this is a horizontal ScrollBar.

private DoubleProperty
max

The maximum value represented by this ScrollBar.

private DoubleProperty
min

The minimum value represented by this ScrollBar.

private ObjectProperty<Orientation>
orientation

The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.

private DoubleProperty
unitIncrement

The amount by which to adjust the ScrollBar when the increment or decrement methods are called.

private DoubleProperty
value

The current value represented by this ScrollBar.

private static final PseudoClass
VERTICAL_PSEUDOCLASS_STATE

Pseud-class indicating this is a vertical ScrollBar.

private DoubleProperty
visibleAmount

Visible amount of the scrollbar's range, typically represented by the size of the scroll bar's thumb.

Constructor Summary

AccessConstructor and Description
public
ScrollBar()

Creates a new horizontal ScrollBar (ie getOrientation() == Orientation.HORIZONTAL).

Method Summary

Modifier and TypeMethod and Description
public void
adjustValue(double
the position
position
)

Adjusts the value property by blockIncrement.

private void
private void
public final DoubleProperty
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public void
decrement()

Decrements the value of the ScrollBar by the unitIncrement

public void
executeAccessibleAction(AccessibleAction
the action to execute
action
,
Object...
optional list of parameters
parameters
)

Overrides javafx.scene.control.Control.executeAccessibleAction.

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<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

protected Boolean
getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value.

public final double
public final double
public final Orientation
public final double
public final double
public final double
public void
increment()

Increments the value of the ScrollBar by the unitIncrement

public final DoubleProperty
public final DoubleProperty
public final ObjectProperty<Orientation>
public Object
queryAccessibleAttribute(AccessibleAttribute
the requested attribute
attribute
,
Object...
optional list of parameters
parameters
)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

public final void
setBlockIncrement(double value)

public final void
setMax(double value)

public final void
setMin(double value)

public final void
public final void
setUnitIncrement(double value)

public final void
setValue(double value)

public final void
setVisibleAmount(double value)

public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertygetBaselineOffsetgetContextMenugetControlChildrengetCssMetaDatagetSkingetTooltipisResizablelayoutChildrenloadSkinClasssetContextMenusetSkinsetTooltipskinClassNamePropertyskinPropertytooltipProperty

Field Detail

blockIncrementback to summary
private DoubleProperty blockIncrement

The amount by which to adjust the scrollbar if the track of the bar is clicked.

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Initialize the style class to 'scroll-bar'. This is the selector class from which CSS can be used to style this control.

HORIZONTAL_PSEUDOCLASS_STATEback to summary
private static final PseudoClass HORIZONTAL_PSEUDOCLASS_STATE

Pseudo-class indicating this is a horizontal ScrollBar.

maxback to summary
private DoubleProperty max

The maximum value represented by this ScrollBar. This should be a value greater than or equal to min. Default value is 100.

minback to summary
private DoubleProperty min

The minimum value represented by this ScrollBar. This should be a value less than or equal to max. Default value is 0.

orientationback to summary
private ObjectProperty<Orientation> orientation

The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.

unitIncrementback to summary
private DoubleProperty unitIncrement

The amount by which to adjust the ScrollBar when the increment or decrement methods are called.

valueback to summary
private DoubleProperty value

The current value represented by this ScrollBar. This value should be between min and max, inclusive.

VERTICAL_PSEUDOCLASS_STATEback to summary
private static final PseudoClass VERTICAL_PSEUDOCLASS_STATE

Pseud-class indicating this is a vertical ScrollBar.

visibleAmountback to summary
private DoubleProperty visibleAmount

Visible amount of the scrollbar's range, typically represented by the size of the scroll bar's thumb.

Constructor Detail

ScrollBarback to summary
public ScrollBar()

Creates a new horizontal ScrollBar (ie getOrientation() == Orientation.HORIZONTAL).

Method Detail

adjustValueback to summary
public void adjustValue(double position)

Adjusts the value property by blockIncrement. The position is the fractional amount between the min and max. For example, it might be 50%. If #minProperty min were 0 and #maxProperty max were 100 and value were 25, then a position of .5 would indicate that we should increment value by blockIncrement. If value were 75, then a position of .5 would indicate that we should decrement value by blockIncrement.

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.

Parameters
position:double

the position

blockDecrementback to summary
private void blockDecrement()
blockIncrementback to summary
private void blockIncrement()
blockIncrementPropertyback to summary
public final DoubleProperty blockIncrementProperty()
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

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 -fx-skin or set explicitly in a sub-class with setSkin(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
decrementback to summary
public void decrement()

Decrements the value of the ScrollBar by the unitIncrement

executeAccessibleActionback to summary
public void executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

Doc from javafx.scene.control.Control.executeAccessibleAction.

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.
If a particular action is not handled, the superclass implementation must be called.

Parameters
action:AccessibleAction

Doc from javafx.scene.Node.executeAccessibleAction.

the action to execute

parameters:Object[]

Doc from javafx.scene.Node.executeAccessibleAction.

optional list of parameters

Annotations
@Override
getBlockIncrementback to summary
public final double getBlockIncrement()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getControlCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Doc from javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Returns:List<CssMetaData<? extends Styleable, ?>>

the unmodifiable list of the control's CSS-styleable properties

Annotations
@Override
Since
JavaFX 8.0
getInitialFocusTraversableback to summary
protected Boolean getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden as by default UI controls have focus traversable set to true, but that is not appropriate for this control.

Returns:Boolean

Doc from javafx.scene.control.Control.getInitialFocusTraversable.

the initial focus traversable state of this control

Annotations
@Override
Since
9
getMaxback to summary
public final double getMax()
getMinback to summary
public final double getMin()
getOrientationback to summary
public final Orientation getOrientation()
getUnitIncrementback to summary
public final double getUnitIncrement()
getValueback to summary
public final double getValue()
getVisibleAmountback to summary
public final double getVisibleAmount()
incrementback to summary
public void increment()

Increments the value of the ScrollBar by the unitIncrement

maxPropertyback to summary
public final DoubleProperty maxProperty()
minPropertyback to summary
public final DoubleProperty minProperty()
orientationPropertyback to summary
public final ObjectProperty<Orientation> orientationProperty()
queryAccessibleAttributeback to summary
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

Doc from javafx.scene.control.Control.queryAccessibleAttribute.

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.
If a particular attribute is not handled, the superclass implementation must be called.

Parameters
attribute:AccessibleAttribute

Doc from javafx.scene.Node.queryAccessibleAttribute.

the requested attribute

parameters:Object[]

Doc from javafx.scene.Node.queryAccessibleAttribute.

optional list of parameters

Returns:Object

Doc from javafx.scene.Node.queryAccessibleAttribute.

the value for the requested attribute

Annotations
@Override
setBlockIncrementback to summary
public final void setBlockIncrement(double value)
setMaxback to summary
public final void setMax(double value)
setMinback to summary
public final void setMin(double value)
setOrientationback to summary
public final void setOrientation(Orientation value)
setUnitIncrementback to summary
public final void setUnitIncrement(double value)
setValueback to summary
public final void setValue(double value)
setVisibleAmountback to summary
public final void setVisibleAmount(double value)
unitIncrementPropertyback to summary
public final DoubleProperty unitIncrementProperty()
valuePropertyback to summary
public final DoubleProperty valueProperty()
visibleAmountPropertyback to summary
public final DoubleProperty visibleAmountProperty()
javafx.scene.control back to summary

private Class ScrollBar.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<ScrollBar, Number>
private static final CssMetaData<ScrollBar, Orientation>
private static final List<CssMetaData<? extends Styleable, ?>>
private static final CssMetaData<ScrollBar, Number>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLOCK_INCREMENTback to summary
private static final CssMetaData<ScrollBar, Number> BLOCK_INCREMENT
ORIENTATIONback to summary
private static final CssMetaData<ScrollBar, Orientation> ORIENTATION
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
UNIT_INCREMENTback to summary
private static final CssMetaData<ScrollBar, Number> UNIT_INCREMENT

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()