Module java.desktop
Package javax.swing

Class JScrollPane.ScrollBar

All Implemented Interfaces:
Adjustable, ImageObserver, MenuContainer, Serializable, Accessible, UIResource
Enclosing class:
JScrollPane

protected class JScrollPane.ScrollBar extends JScrollBar implements UIResource
By default JScrollPane creates scrollbars that are instances of this class. Scrollbar overrides the getUnitIncrement and getBlockIncrement methods so that, if the viewport's view is a Scrollable, the view is asked to compute these values. Unless the unit/block increment have been explicitly set.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see XMLEncoder.

See Also:
  • Constructor Details

    • ScrollBar

      public ScrollBar(int orientation)
      Creates a scrollbar with the specified orientation. The options are:
      • ScrollPaneConstants.VERTICAL
      • ScrollPaneConstants.HORIZONTAL
      Parameters:
      orientation - an integer specifying one of the legal orientation values shown above
      Since:
      1.4
  • Method Details

    • setUnitIncrement

      public void setUnitIncrement(int unitIncrement)
      Messages super to set the value, and resets the unitIncrementSet instance variable to true.
      Specified by:
      setUnitIncrement in interface Adjustable
      Overrides:
      setUnitIncrement in class JScrollBar
      Parameters:
      unitIncrement - the new unit increment value, in pixels
      See Also:
    • getUnitIncrement

      public int getUnitIncrement(int direction)
      Computes the unit increment for scrolling if the viewport's view is a Scrollable object. Otherwise return super.getUnitIncrement.
      Overrides:
      getUnitIncrement in class JScrollBar
      Parameters:
      direction - less than zero to scroll up/left, greater than zero for down/right
      Returns:
      an integer, in pixels, containing the unit increment
      See Also:
    • setBlockIncrement

      public void setBlockIncrement(int blockIncrement)
      Messages super to set the value, and resets the blockIncrementSet instance variable to true.
      Specified by:
      setBlockIncrement in interface Adjustable
      Overrides:
      setBlockIncrement in class JScrollBar
      Parameters:
      blockIncrement - the new block increment value, in pixels
      See Also:
    • getBlockIncrement

      public int getBlockIncrement(int direction)
      Computes the block increment for scrolling if the viewport's view is a Scrollable object. Otherwise the blockIncrement equals the viewport's width or height. If there's no viewport return super.getBlockIncrement.
      Overrides:
      getBlockIncrement in class JScrollBar
      Parameters:
      direction - less than zero to scroll up/left, greater than zero for down/right
      Returns:
      an integer, in pixels, containing the block increment
      See Also: