javax.swing
Class JScrollPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants

public class JScrollPane
extends JComponent
implements Accessible, ScrollPaneConstants

A component that embeds another component and enables it to be scrolled both in horizontal and vertical direction.

Property Stored in Bound?
columnHeader scrollPane yes
columnHeaderView columnHeader no
componentOrientation scrollPane yes
horizontalScrollBar scrollPane yes
horizontalScrollBarPolicy scrollPane yes
layout scrollPane yes
rowHeader scrollPane yes
rowHeaderView rowHeader no
validateRoot scrollPane no
verticalScrollBar scrollPane yes
verticalScrollBarPolicy scrollPane yes
viewport scrollPane yes
viewportBorder scrollPane yes
viewportBorderBounds scrollPane no
viewportView viewport no
wheelScrollingEnabled scrollPane yes

See Also:
Serialized Form

Nested Class Summary
protected  class JScrollPane.AccessibleJScrollPane
          Provides accessibility support for the JScrollPane.
protected  class JScrollPane.ScrollBar
           
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JViewport columnHeader
           
protected  JScrollBar horizontalScrollBar
           
protected  int horizontalScrollBarPolicy
           
protected  Component lowerLeft
           
protected  Component lowerRight
           
protected  JViewport rowHeader
           
protected  Component upperLeft
           
protected  Component upperRight
           
protected  JScrollBar verticalScrollBar
           
protected  int verticalScrollBarPolicy
           
protected  JViewport viewport
           
 
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 javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JScrollPane()
          Creates a new JScrollPane without a view.
JScrollPane(Component view)
          Creates a new JScrollPane that embeds the specified view component, displaying vertical and horizontal scrollbars as needed.
JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
          Creates a new JScrollPane that embeds the specified view component; The scrollbar policies are set to vsbPolicy and hsbPolicy.
JScrollPane(int vsbPolicy, int hsbPolicy)
          Creates a new JScrollPane without a view; The scrollbar policies are set to vsbPolicy and hsbPolicy.
 
Method Summary
 JScrollBar createHorizontalScrollBar()
           
 JScrollBar createVerticalScrollBar()
           
protected  JViewport createViewport()
           
 AccessibleContext getAccessibleContext()
          Returns the accessible context associated with this JScrollPane.
 JViewport getColumnHeader()
           
 Component getCorner(String key)
           
 JScrollBar getHorizontalScrollBar()
           
 int getHorizontalScrollBarPolicy()
           
 JViewport getRowHeader()
           
 ScrollPaneUI getUI()
          This method returns the scrollpane's UI delegate.
 String getUIClassID()
          Get the value of the UIClassID property.
 JScrollBar getVerticalScrollBar()
           
 int getVerticalScrollBarPolicy()
           
 JViewport getViewport()
           
 Border getViewportBorder()
           
 Rectangle getViewportBorderBounds()
           
 boolean isValidateRoot()
          Return true if this component is a validation root; this will cause calls to Container.invalidate() in this component's children to be "captured" at this component, and not propagate to its parents.
 boolean isWheelScrollingEnabled()
           
 void setColumnHeader(JViewport h)
           
 void setColumnHeaderView(Component c)
           
 void setComponentOrientation(ComponentOrientation co)
          Sets the text layout orientation of this component.
 void setCorner(String key, Component c)
           
 void setHorizontalScrollBar(JScrollBar h)
           
 void setHorizontalScrollBarPolicy(int h)
           
 void setLayout(LayoutManager l)
          Sets the layout manager for this container to the specified layout manager.
 void setRowHeader(JViewport v)
           
 void setRowHeaderView(Component c)
           
 void setUI(ScrollPaneUI ui)
          This method sets the scrollpane's UI delegate.
 void setVerticalScrollBar(JScrollBar v)
           
 void setVerticalScrollBarPolicy(int v)
           
 void setViewport(JViewport v)
           
 void setViewportBorder(Border b)
           
 void setViewportView(Component view)
           
 void setWheelScrollingEnabled(boolean b)
           
 void updateUI()
          This method should be overridden in subclasses.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

columnHeader

protected JViewport columnHeader

rowHeader

protected JViewport rowHeader

lowerLeft

protected Component lowerLeft

lowerRight

protected Component lowerRight

upperLeft

protected Component upperLeft

upperRight

protected Component upperRight

horizontalScrollBar

protected JScrollBar horizontalScrollBar

horizontalScrollBarPolicy

protected int horizontalScrollBarPolicy

verticalScrollBar

protected JScrollBar verticalScrollBar

verticalScrollBarPolicy

protected int verticalScrollBarPolicy

viewport

protected JViewport viewport
Constructor Detail

JScrollPane

public JScrollPane()
Creates a new JScrollPane without a view. The scrollbar policy is set to ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED and ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED.


JScrollPane

public JScrollPane(Component view)
Creates a new JScrollPane that embeds the specified view component, displaying vertical and horizontal scrollbars as needed.

Parameters:
view - the component that is embedded inside the JScrollPane

JScrollPane

public JScrollPane(int vsbPolicy,
                   int hsbPolicy)
Creates a new JScrollPane without a view; The scrollbar policies are set to vsbPolicy and hsbPolicy.

Parameters:
vsbPolicy - the vertical scrollbar policy to set
hsbPolicy - the vertical scrollbar policy to set
See Also:
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER

JScrollPane

public JScrollPane(Component view,
                   int vsbPolicy,
                   int hsbPolicy)
Creates a new JScrollPane that embeds the specified view component; The scrollbar policies are set to vsbPolicy and hsbPolicy.

Parameters:
vsbPolicy - the vertical scrollbar policy to set
hsbPolicy - the vertical scrollbar policy to set
See Also:
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
Method Detail

getColumnHeader

public JViewport getColumnHeader()

getCorner

public Component getCorner(String key)

getHorizontalScrollBar

public JScrollBar getHorizontalScrollBar()

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()

getRowHeader

public JViewport getRowHeader()

getVerticalScrollBar

public JScrollBar getVerticalScrollBar()

getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()

getViewport

public JViewport getViewport()

getViewportBorder

public Border getViewportBorder()

getViewportBorderBounds

public Rectangle getViewportBorderBounds()

isWheelScrollingEnabled

public boolean isWheelScrollingEnabled()

setComponentOrientation

public void setComponentOrientation(ComponentOrientation co)
Description copied from class: Component
Sets the text layout orientation of this component. New components default to UNKNOWN (which behaves like LEFT_TO_RIGHT). This method affects only the current component, while Component.applyComponentOrientation(ComponentOrientation) affects the entire hierarchy.

Overrides:
setComponentOrientation in class Component
Parameters:
co - the new orientation (null is accepted)
See Also:
Component.getComponentOrientation()

setColumnHeader

public void setColumnHeader(JViewport h)

setColumnHeaderView

public void setColumnHeaderView(Component c)

setCorner

public void setCorner(String key,
                      Component c)

setHorizontalScrollBar

public void setHorizontalScrollBar(JScrollBar h)

setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int h)

setLayout

public void setLayout(LayoutManager l)
Description copied from class: Container
Sets the layout manager for this container to the specified layout manager.

Overrides:
setLayout in class Container
Parameters:
l - The new layout manager for this container.

setRowHeader

public void setRowHeader(JViewport v)

setRowHeaderView

public void setRowHeaderView(Component c)

setVerticalScrollBar

public void setVerticalScrollBar(JScrollBar v)

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int v)

setWheelScrollingEnabled

public void setWheelScrollingEnabled(boolean b)

setViewport

public void setViewport(JViewport v)

setViewportBorder

public void setViewportBorder(Border b)

setViewportView

public void setViewportView(Component view)

isValidateRoot

public boolean isValidateRoot()
Description copied from class: JComponent
Return true if this component is a validation root; this will cause calls to Container.invalidate() in this component's children to be "captured" at this component, and not propagate to its parents. For most components this should return false, but some components such as JViewport will want to return true.

Overrides:
isValidateRoot in class JComponent
Returns:
Whether this component is a validation root

createHorizontalScrollBar

public JScrollBar createHorizontalScrollBar()

createVerticalScrollBar

public JScrollBar createVerticalScrollBar()

createViewport

protected JViewport createViewport()

getUIClassID

public String getUIClassID()
Description copied from class: JComponent
Get the value of the UIClassID property. This property should be a key in the UIDefaults table managed by UIManager, the value of which is the name of a class to load for the component's JComponent.ui property.

Overrides:
getUIClassID in class JComponent
Returns:
A "symbolic" name which will map to a class to use for the component's UI, such as "ComponentUI"
See Also:
JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

updateUI

public void updateUI()
Description copied from class: JComponent
This method should be overridden in subclasses. In JComponent, the method does nothing. In subclasses, it should a UI delegate (corresponding to the symbolic name returned from JComponent.getUIClassID()) from the UIManager, and calls JComponent.setUI(javax.swing.plaf.ComponentUI) with the new delegate.

Overrides:
updateUI in class JComponent

getUI

public ScrollPaneUI getUI()
This method returns the scrollpane's UI delegate.

Returns:
The scrollpane's UI delegate.

setUI

public void setUI(ScrollPaneUI ui)
This method sets the scrollpane's UI delegate.

Parameters:
ui - The scrollpane's UI delegate.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Returns the accessible context associated with this JScrollPane.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
the accessible context associated with this JScrollPane