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 :

    
     import javafx.scene.control.ScrollBar;
    
     ScrollBar s1 = new ScrollBar();
     s1.setOrientation(Orientation.VERTICAL);
     
    Implementation of ScrollBar According to JavaFX UI Control API Specification
    Since:
    JavaFX 2.0
    • Constructor Detail

      • ScrollBar

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

      • setMin

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

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

        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.
        See Also:
        getMin(), setMin(double)
      • setMax

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

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

        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.
        See Also:
        getMax(), setMax(double)
      • setValue

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

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

        public final void setOrientation​(Orientation value)
        Sets the value of the property orientation.
        Property description:
        The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.
      • getOrientation

        public final Orientation getOrientation()
        Gets the value of the property orientation.
        Property description:
        The orientation of the ScrollBar can either be HORIZONTAL or VERTICAL.
      • setUnitIncrement

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

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

        public final void setBlockIncrement​(double value)
        Sets the value of the property blockIncrement.
        Property description:
        The amount by which to adjust the scrollbar if the track of the bar is clicked.
      • getBlockIncrement

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

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

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

        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

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

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

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

        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