javax.swing

Class JScrollPane

Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, ScrollPaneConstants, Serializable

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

TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui

Fields inherited from class java.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

Fields inherited from interface java.awt.image.ImageObserver

ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

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

Constructor Summary

JScrollPane()
Creates a new JScrollPane without a view.
JScrollPane(int vsbPolicy, int hsbPolicy)
Creates a new JScrollPane without a view; The scrollbar policies are set to vsbPolicy and hsbPolicy.
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.

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 JComponent.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, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, updateUI

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree

Methods inherited from class java.awt.Component

action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

columnHeader

protected JViewport columnHeader

horizontalScrollBar

protected JScrollBar horizontalScrollBar

horizontalScrollBarPolicy

protected int horizontalScrollBarPolicy

lowerLeft

protected Component lowerLeft

lowerRight

protected Component lowerRight

rowHeader

protected JViewport rowHeader

upperLeft

protected Component upperLeft

upperRight

protected Component upperRight

verticalScrollBar

protected JScrollBar verticalScrollBar

verticalScrollBarPolicy

protected int verticalScrollBarPolicy

viewport

protected JViewport viewport

Constructor Details

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(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

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(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

Method Details

createHorizontalScrollBar

public JScrollBar createHorizontalScrollBar()

createVerticalScrollBar

public JScrollBar createVerticalScrollBar()

createViewport

protected JViewport createViewport()

getAccessibleContext

public AccessibleContext getAccessibleContext()
Returns the accessible context associated with this JScrollPane.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface JComponent
Returns:
the accessible context associated with this JScrollPane

getColumnHeader

public JViewport getColumnHeader()

getCorner

public Component getCorner(String key)

getHorizontalScrollBar

public JScrollBar getHorizontalScrollBar()

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()

getRowHeader

public JViewport getRowHeader()

getUI

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

getUIClassID

public String getUIClassID()
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 interface JComponent
Returns:
A "symbolic" name which will map to a class to use for the component's UI, such as "ComponentUI"

getVerticalScrollBar

public JScrollBar getVerticalScrollBar()

getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()

getViewport

public JViewport getViewport()

getViewportBorder

public Border getViewportBorder()

getViewportBorderBounds

public Rectangle getViewportBorderBounds()

isValidateRoot

public boolean isValidateRoot()
Return true if this component is a validation root; this will cause calls to JComponent.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 interface JComponent
Returns:
Whether this component is a validation root

isWheelScrollingEnabled

public boolean isWheelScrollingEnabled()

setColumnHeader

public void setColumnHeader(JViewport h)

setColumnHeaderView

public void setColumnHeaderView(Component c)

setComponentOrientation

public void setComponentOrientation(ComponentOrientation co)
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 interface Component
Parameters:

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)
Sets the layout manager for this container to the specified layout manager.
Overrides:
setLayout in interface Container
Parameters:

setRowHeader

public void setRowHeader(JViewport v)

setRowHeaderView

public void setRowHeaderView(Component c)

setUI

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

setVerticalScrollBar

public void setVerticalScrollBar(JScrollBar v)

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int v)

setViewport

public void setViewport(JViewport v)

setViewportBorder

public void setViewportBorder(Border b)

setViewportView

public void setViewportView(Component view)

setWheelScrollingEnabled

public void setWheelScrollingEnabled(boolean b)

updateUI

public void updateUI()
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(ComponentUI) with the new delegate.
Overrides:
updateUI in interface JComponent

JScrollPane.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.