javax.swing
Class JScrollBar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JScrollBar
All Implemented Interfaces:
Accessible, Adjustable, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
JScrollPane.ScrollBar
public class JScrollBar
extends JComponent
implements Adjustable, Accessible

An implementation of a scrollbar. The user positions the knob in the scrollbar to determine the contents of the viewing area. The program typically adjusts the display so that the end of the scrollbar represents the end of the displayable contents, or 100% of the contents. The start of the scrollbar is the beginning of the displayable contents, or 0%. The position of the knob within those bounds then translates to the corresponding percentage of the displayable contents.

Typically, as the position of the knob in the scrollbar changes a corresponding change is made to the position of the JViewport on the underlying view, changing the contents of the JViewport.

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.

See Also:
JScrollPane

 

Nested Class Summary

protected  class JScrollBar.AccessibleJScrollBar
    This class implements accessibility support for the JScrollBar class.
 
Nested classes inherited from class javax.swing.JComponent
 
Nested classes inherited from class java.awt.Container
 
Nested classes inherited from class java.awt.Component
Component.BltBufferStrategy, Component.FlipBufferStrategy
 

 

Field Summary

protected  int blockIncrement
    
protected  BoundedRangeModel model
    The model that represents the scrollbar's minimum, maximum, extent (aka "visibleAmount") and current value.
protected  int orientation
    
protected  int unitIncrement
    
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.Adjustable
HORIZONTAL, NO_ORIENTATION, VERTICAL
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 

 

Constructor Summary

JScrollBar()
    Creates a vertical scrollbar with the following initial values:
JScrollBar(int orientation)
    Creates a scrollbar with the specified orientation and the following initial values:
JScrollBar(int orientation, int value, int extent, int min, int max)
    Creates a scrollbar with the specified orientation, value, extent, minimum, and maximum.
 

 

Method Summary

 void addAdjustmentListener(AdjustmentListener l)
    Adds an AdjustmentListener.
protected  void fireAdjustmentValueChanged(int id, int type, int value)
    
 AccessibleContext getAccessibleContext()
    Gets the AccessibleContext associated with this JScrollBar.
 AdjustmentListener[] getAdjustmentListeners()
    Returns an array of all the AdjustmentListeners added to this JScrollBar with addAdjustmentListener().
 int getBlockIncrement()
    For backwards compatibility with java.awt.Scrollbar.
 int getBlockIncrement(int direction)
    Returns the amount to change the scrollbar's value by, given a block (usually "page") up/down request.
 int getMaximum()
    The maximum value of the scrollbar is maximum - extent.
 Dimension getMaximumSize()
    The scrollbar is flexible along it's scrolling axis and rigid along the other axis.
 int getMinimum()
    Returns the minimum value supported by the scrollbar (usually zero).
 Dimension getMinimumSize()
    The scrollbar is flexible along it's scrolling axis and rigid along the other axis.
 BoundedRangeModel getModel()
    Returns data model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.
 int getOrientation()
    Returns the component's orientation (horizontal or vertical).
 ScrollBarUI getUI()
    Returns the delegate that implements the look and feel for this component.
 String getUIClassID()
    Returns the name of the LookAndFeel class for this component.
 int getUnitIncrement()
    For backwards compatibility with java.awt.Scrollbar.
 int getUnitIncrement(int direction)
    Returns the amount to change the scrollbar's value by, given a unit up/down request.
 int getValue()
    Returns the scrollbar's value.
 boolean getValueIsAdjusting()
    True if the scrollbar knob is being dragged.
 int getVisibleAmount()
    Returns the scrollbar's extent, aka its "visibleAmount".
protected  String paramString()
    Returns a string representation of this JScrollBar.
 void removeAdjustmentListener(AdjustmentListener l)
    Removes an AdjustmentEvent listener.
 void setBlockIncrement(int blockIncrement)
    Sets the blockIncrement property.
 void setEnabled(boolean x)
    Enables the component so that the knob position can be changed.
 void setMaximum(int maximum)
    Sets the model's maximum property.
 void setMinimum(int minimum)
    Sets the model's minimum property.
 void setModel(BoundedRangeModel newModel)
    Sets the model that handles the scrollbar's four fundamental properties: minimum, maximum, value, extent.
 void setOrientation(int orientation)
    Set the scrollbar's orientation to either VERTICAL or HORIZONTAL.
 void setUI(ScrollBarUI ui)
    Sets the L&F object that renders this component.
 void setUnitIncrement(int unitIncrement)
    Sets the unitIncrement property.
 void setValue(int value)
    Sets the scrollbar's value.
 void setValueIsAdjusting(boolean b)
    Sets the model's valueIsAdjusting property.
 void setValues(int newValue, int newExtent, int newMin, int newMax)
    Sets the four BoundedRangeModel properties after forcing the arguments to obey the usual constraints:
 void setVisibleAmount(int extent)
    Set the model's extent property.
 void updateUI()
    Overrides JComponent.updateUI.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent,