Class ScrollBar

All Implemented Interfaces:
Styleable, EventTarget, Skinnable

public class ScrollBar extends Control
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
  • Property Details Link icon

  • Constructor Details Link icon

    • ScrollBar Link icon

      public ScrollBar()
      Creates a new horizontal ScrollBar (ie getOrientation() == Orientation.HORIZONTAL).
  • Method Details Link icon

    • setMin Link icon

      public final void setMin(double value)
      Sets the value of the min property.
      Property description:
      The minimum value represented by this ScrollBar. This should be a value less than or equal to max. Default value is 0.
      Parameters:
      value - the value for the min property
      See Also:
    • getMin Link icon

      public final double getMin()
      Gets the value of the min property.
      Property description:
      The minimum value represented by this ScrollBar. This should be a value less than or equal to max. Default value is 0.
      Returns:
      the value of the min property
      See Also:
    • minProperty Link icon

      public final DoubleProperty minProperty()
      The minimum value represented by this ScrollBar. This should be a value less than or equal to max. Default value is 0.
      Returns:
      the min property
      See Also:
    • setMax Link icon

      public final void setMax(double value)
      Sets the value of the max property.
      Property description:
      The maximum value represented by this ScrollBar. This should be a value greater than or equal to min. Default value is 100.
      Parameters:
      value - the value for the max property
      See Also:
    • getMax Link icon

      public final double getMax()
      Gets the value of the max property.
      Property description:
      The maximum value represented by this ScrollBar. This should be a value greater than or equal to min. Default value is 100.
      Returns:
      the value of the max property
      See Also:
    • maxProperty Link icon

      public final DoubleProperty maxProperty()
      The maximum value represented by this ScrollBar. This should be a value greater than or equal to min. Default value is 100.
      Returns:
      the max property
      See Also:
    • setValue Link icon

      public final void setValue(double value)
      Sets the value of the value property.
      Property description:
      The current value represented by this ScrollBar. This value should be between min and max, inclusive.
      Parameters:
      value - the value for the value property
      See Also:
    • getValue Link icon

      public final double getValue()
      Gets the value of the value property.
      Property description:
      The current value represented by this ScrollBar. This value should be between min and max, inclusive.
      Returns:
      the value of the value property
      See Also:
    • valueProperty Link icon

      public final DoubleProperty valueProperty()
      The current value represented by this ScrollBar. This value should be between min and max, inclusive.
      Returns:
      the value property
      See Also:
    • setOrientation Link icon

      public final void setOrientation(Orientation value)
      Sets the value of the orientation property.
      Property description:
      The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.
      Parameters:
      value - the value for the orientation property
      See Also:
    • getOrientation Link icon

      public final Orientation getOrientation()
      Gets the value of the orientation property.
      Property description:
      The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.
      Returns:
      the value of the orientation property
      See Also:
    • orientationProperty Link icon

      public final ObjectProperty<Orientation> orientationProperty()
      The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.
      Returns:
      the orientation property
      See Also:
    • setUnitIncrement Link icon

      public final void setUnitIncrement(double value)
      Sets the value of the unitIncrement property.
      Property description:
      The amount by which to adjust the ScrollBar when the increment or decrement methods are called.
      Parameters:
      value - the value for the unitIncrement property
      See Also:
    • getUnitIncrement Link icon

      public final double getUnitIncrement()
      Gets the value of the unitIncrement property.
      Property description:
      The amount by which to adjust the ScrollBar when the increment or decrement methods are called.
      Returns:
      the value of the unitIncrement property
      See Also:
    • unitIncrementProperty Link icon

      public final DoubleProperty unitIncrementProperty()
      The amount by which to adjust the ScrollBar when the increment or decrement methods are called.
      Returns:
      the unitIncrement property
      See Also:
    • setBlockIncrement Link icon

      public final void setBlockIncrement(double value)
      Sets the value of the blockIncrement property.
      Property description:
      The amount by which to adjust the scrollbar if the track of the bar is clicked.
      Parameters:
      value - the value for the blockIncrement property
      See Also:
    • getBlockIncrement Link icon

      public final double getBlockIncrement()
      Gets the value of the blockIncrement property.
      Property description:
      The amount by which to adjust the scrollbar if the track of the bar is clicked.
      Returns:
      the value of the blockIncrement property
      See Also:
    • blockIncrementProperty Link icon

      public final DoubleProperty blockIncrementProperty()
      The amount by which to adjust the scrollbar if the track of the bar is clicked.
      Returns:
      the blockIncrement property
      See Also:
    • setVisibleAmount Link icon

      public final void setVisibleAmount(double value)
      Sets the value of the visibleAmount property.
      Property description:
      Visible amount of the scrollbar's range, typically represented by the size of the scroll bar's thumb.
      Parameters:
      value - the value for the visibleAmount property
      See Also:
    • getVisibleAmount Link icon

      public final double getVisibleAmount()
      Gets the value of the visibleAmount property.
      Property description:
      Visible amount of the scrollbar's range, typically represented by the size of the scroll bar's thumb.
      Returns:
      the value of the visibleAmount property
      See Also:
    • visibleAmountProperty Link icon

      public final DoubleProperty visibleAmountProperty()
      Visible amount of the scrollbar's range, typically represented by the size of the scroll bar's thumb.
      Returns:
      the visibleAmount property
      See Also:
    • adjustValue Link icon

      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 - the position
    • increment Link icon

      public void increment()
      Increments the value of the ScrollBar by the unitIncrement
    • decrement Link icon

      public void decrement()
      Decrements the value of the ScrollBar by the unitIncrement
    • getClassCssMetaData Link icon

      public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
      Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.
      Returns:
      the CssMetaData
      Since:
      JavaFX 8.0
    • getControlCssMetaData Link icon

      public List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
      Gets the unmodifiable list of the control's CSS-styleable properties.
      Overrides:
      getControlCssMetaData in class Control
      Returns:
      the unmodifiable list of the control's CSS-styleable properties
      Since:
      JavaFX 8.0
    • getInitialFocusTraversable Link icon

      protected Boolean 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.
      Overrides:
      getInitialFocusTraversable in class Control
      Returns:
      the initial focus traversable state of this control
      Since:
      9