protected class

JScrollPane.ScrollBar

extends JScrollBar
implements UIResource
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ javax.swing.JComponent
         ↳ javax.swing.JScrollBar
           ↳ javax.swing.JScrollPane.ScrollBar

Class Overview

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 JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

Summary

[Expand]
Inherited Constants
From class javax.swing.JComponent
From class java.awt.Component
From interface java.awt.Adjustable
From interface java.awt.image.ImageObserver
[Expand]
Inherited Fields
From class javax.swing.JScrollBar
From class javax.swing.JComponent
Public Constructors
JScrollPane.ScrollBar(int orientation)
Creates a scrollbar with the specified orientation.
Public Methods
int getBlockIncrement(int direction)
Computes the block increment for scrolling if the viewport's view is a Scrollable object.
int getUnitIncrement(int direction)
Computes the unit increment for scrolling if the viewport's view is a Scrollable object.
void setBlockIncrement(int blockIncrement)
Messages super to set the value, and resets the blockIncrementSet instance variable to true.
void setUnitIncrement(int unitIncrement)
Messages super to set the value, and resets the unitIncrementSet instance variable to true.
[Expand]
Inherited Methods
From class javax.swing.JScrollBar
From class javax.swing.JComponent
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface java.awt.Adjustable
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface javax.accessibility.Accessible

Public Constructors

public JScrollPane.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

Public Methods

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.

Parameters
direction less than zero to scroll up/left, greater than zero for down/right
Returns
  • an integer, in pixels, containing the block increment

public int getUnitIncrement (int direction)

Computes the unit increment for scrolling if the viewport's view is a Scrollable object. Otherwise return super.getUnitIncrement.

Parameters
direction less than zero to scroll up/left, greater than zero for down/right
Returns
  • an integer, in pixels, containing the unit increment

public void setBlockIncrement (int blockIncrement)

Messages super to set the value, and resets the blockIncrementSet instance variable to true.

Parameters
blockIncrement the new block increment value, in pixels

public void setUnitIncrement (int unitIncrement)

Messages super to set the value, and resets the unitIncrementSet instance variable to true.

Parameters
unitIncrement the new unit increment value, in pixels