站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档

Java(TM) 2 Platform, Standard Edition, v1.2.2 API Specification: Class JScrollPane - JDK 5 Documentation v1.2.2, Java 2 SDK 英文文档

JavaTM 2 Platform
Standard Edition

javax.swing
Class JScrollPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JScrollPane

public class JScrollPane
extends JComponent
implements ScrollPaneConstants, Accessible

A specialized container that manages a viewport, optional vertical and horizontal scrollbars, and optional row and column heading viewports.

The JViewport provides a window, or "viewport" onto a data source -- for example, a text file. That data source is the "scrollable client" (aka data model) displayed by the JViewport view. A JScrollPane basically consists of JScrollBars, a JViewport, and the wiring between them, as shown in the diagram at right.

In addition to the scroll bars and viewport, a JScrollPane can have a column header and a row header. Each of these is a JViewport object that you specify with setRowHeaderView, and setColumnHeaderView. The column header viewport automatically scrolls left and right, tracking the left-right scrolling of the main viewport. (It never scrolls vertically, however.) The row header acts in a similar fashion.

By default, the corners are empty. You can put a component into a corner using setCorner, in case you there is some function or decoration you would like to add to the scroll pane. The size of corner components is entirely determined by the size of the headers and scroll bars that surround them.

To add a border around the main viewport, you can use setViewportBorder. (Of course, you can also add a border around the whole scroll pane using setBorder.)

For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JScrollPane key assignments.

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. A future release of Swing will provide support for long term persistence.

See Also:
JScrollBar, JViewport, setViewportView(java.awt.Component), setRowHeaderView(java.awt.Component), setColumnHeaderView(java.awt.Component), setCorner(java.lang.String, java.awt.Component), setViewportBorder(javax.swing.border.Border), Serialized Form

Inner Class Summary
protected  class JScrollPane.AccessibleJScrollPane
          The class used to obtain the accessible role for this object.
protected  class JScrollPane.ScrollBar
          By default JScrollPane creates scrollbars that are instances of this class.
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  JViewport columnHeader
          The column header child.
protected  JScrollBar horizontalScrollBar
          The scrollpane's horizontal scrollbar child.
protected  int horizontalScrollBarPolicy
          The display policy for the horizontal scrollbar.
protected  Component lowerLeft
          The component to display in the lower left corner.
protected  Component lowerRight
          The component to display in the lower right corner.
protected  JViewport rowHeader
          The row header child.
protected  Component upperLeft
          The component to display in the upper left corner.
protected  Component upperRight
          The component to display in the upper right corner.
protected  JScrollBar verticalScrollBar
          The scrollpane's vertical scrollbar child.
protected  int verticalScrollBarPolicy
          The display policy for the vertical scrollbar.
protected  JViewport viewport
          The scrollpanes viewport child.
 
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_LEFT_CORNER, LOWER_RIGHT_CORNER, ROW_HEADER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Constructor Summary
JScrollPane()
          Create an empty (no viewport view) JScrollPane where both horizontal and vertical scrollbars appear when needed.
JScrollPane(Component view)
          Create a JScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.
JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
          Create a JScrollPane that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars.
JScrollPane(int vsbPolicy, int hsbPolicy)
          Create an empty (no viewport view) JScrollPane with specified scrollbar policies.
 
Method Summary
 JScrollBar createHorizontalScrollBar()
          Used by ScrollPaneUI implementations to create the horizontal scrollbar.
 JScrollBar createVerticalScrollBar()
          Used by ScrollPaneUI implementations to create the vertical scrollbar.
protected  JViewport createViewport()
          Returns a new JViewport by default.
 AccessibleContext getAccessibleContext()
          Get the AccessibleContext associated with this JComponent
 JViewport getColumnHeader()
          Returns the column header.
 Component getCorner(String key)
          Returns the component at the specified corner.
 JScrollBar getHorizontalScrollBar()
          Returns the horizontal scroll bar.
 int getHorizontalScrollBarPolicy()
          Returns the horizontal scroll bar policy value.
 JViewport getRowHeader()
          Returns the row header.
 ScrollPaneUI getUI()
          Returns the L&F object that renders this component.
 String getUIClassID()
          Returns the key used to look up the ScrollPaneUI class that provides the look and feel for JScrollPane.
 JScrollBar getVerticalScrollBar()
          Returns the vertical scroll bar.
 int getVerticalScrollBarPolicy()
          Returns the vertical scroll bar policy value.
 JViewport getViewport()
          Returns the current JViewport.
 Border getViewportBorder()
          Returns the value of the viewportBorder property.
 Rectangle getViewportBorderBounds()
          Returns the bounds of the viewport border.
 boolean isOpaque()
          Returns true if this component paints every pixel in its range.
 boolean isValidateRoot()
          Calls to revalidate() on any descendant of this JScrollPane, e.g.
protected  String paramString()
          Returns a string representation of this JScrollPane.
 void setColumnHeader(JViewport columnHeader)
          If an old columnHeader exists, remove it.
 void setColumnHeaderView(Component view)
          Creates a column-header viewport if neccessary, sets its view and then adds the column-header viewport to the scrollpane.
 void setCorner(String key, Component corner)
          Adds a child that will appear in one of the scroll panes corners, if there's room.
 void setHorizontalScrollBar(JScrollBar horizontalScrollBar)
          Add the scrollbar that controls the viewports horizontal view position to the scrollpane.
 void setHorizontalScrollBarPolicy(int policy)
          Determines when the horizontal scrollbar appears in the scrollpane.
 void setLayout(LayoutManager layout)
          Sets the layout manager for this JScrollPane.
 void setRowHeader(JViewport rowHeader)
          If an old rowHeader exists, remove it.
 void setRowHeaderView(Component view)
          Creates a row-header viewport if neccessary, sets its view and then adds the row-header viewport to the scrollpane.
 void setUI(ScrollPaneUI ui)
          Sets the ScrollPaneUI object that provides the look and feel for this component.
 void setVerticalScrollBar(JScrollBar verticalScrollBar)
          Add the scrollbar that controls the viewports vertical view position to the scrollpane.
 void setVerticalScrollBarPolicy(int policy)
          Determines when the vertical scrollbar appears in the scrollpane.
 void setViewport(JViewport viewport)
          Remove the old viewport (if there is one), force the viewPosition of the new viewport to be in the +x,+y quadrant, sync up the row and column headers (if there are any) with the new viewport, and finally sync the scrollbars and headers with the new viewport.
 void setViewportBorder(Border viewportBorder)
          Add a border around the viewport.
 void setViewportView(Component view)
          Creates a viewport if neccessary and then sets its view.
 void updateUI()
          To be called when the default look and feel changes.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

verticalScrollBarPolicy

protected int verticalScrollBarPolicy
The display policy for the vertical scrollbar. The default is JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED.
See Also:
setVerticalScrollBarPolicy(int)

horizontalScrollBarPolicy

protected int horizontalScrollBarPolicy
The display policy for the horizontal scrollbar. The default is JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED.
See Also:
setHorizontalScrollBarPolicy(int)

viewport

protected JViewport viewport
The scrollpanes viewport child. Default is an empty JViewport.
See Also:
setViewport(javax.swing.JViewport)

verticalScrollBar

protected JScrollBar verticalScrollBar
The scrollpane's vertical scrollbar child. Default is a JScrollBar.
See Also:
setVerticalScrollBar(javax.swing.JScrollBar)

horizontalScrollBar

protected JScrollBar horizontalScrollBar
The scrollpane's horizontal scrollbar child. Default is a JScrollBar.
See Also:
setHorizontalScrollBar(javax.swing.JScrollBar)

rowHeader

protected JViewport rowHeader
The row header child. Default is null.
See Also:
setRowHeader(javax.swing.JViewport)

columnHeader

protected JViewport columnHeader
The column header child. Default is null.
See Also:
setColumnHeader(javax.swing.JViewport)

lowerLeft

protected Component lowerLeft
The component to display in the lower left corner. Default is null.
See Also:
setCorner(java.lang.String, java.awt.Component)

lowerRight

protected Component lowerRight
The component to display in the lower right corner. Default is null.
See Also:
setCorner(java.lang.String, java.awt.Component)

upperLeft

protected Component upperLeft
The component to display in the upper left corner. Default is null.
See Also:
setCorner(java.lang.String, java.awt.Component)

upperRight

protected Component upperRight
The component to display in the upper right corner. Default is null.
See Also:
setCorner(java.lang.String, java.awt.Component)
Constructor Detail

JScrollPane

public JScrollPane(Component view,
                   int vsbPolicy,
                   int hsbPolicy)
Create a JScrollPane that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars. The scrollbar policies specify when the scrollbars are displayed, e.g. if vsbPolicy is VERTICAL_SCROLLBAR_AS_NEEDED then the vertical scrollbar only appears if the view doesn't fit vertically. The available policies settings are listed at setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).
Parameters:
view - the Component to display in the scrollpanes viewport
vsbPolicy - an int that specifies the vertical scrollbar policy
hsbPolicy - an int that specifies the horizontal scrollbar policy
See Also:
setViewportView(java.awt.Component)

JScrollPane

public JScrollPane(Component view)
Create a JScrollPane that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.
Parameters:
view - the Component to display in the scrollpanes viewport
See Also:
setViewportView(java.awt.Component)

JScrollPane

public JScrollPane(int vsbPolicy,
                   int hsbPolicy)
Create an empty (no viewport view) JScrollPane with specified scrollbar policies. The available policies settings are listed at setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).
Parameters:
vsbPolicy - an int that specifies the vertical scrollbar policy
hsbPolicy - an int that specifies the horizontal scrollbar policy
See Also:
setViewportView(java.awt.Component)

JScrollPane

public JScrollPane()
Create an empty (no viewport view) JScrollPane where both horizontal and vertical scrollbars appear when needed.
Method Detail

getUI

public ScrollPaneUI getUI()
Returns the L&F object that renders this component.
Returns:
the ScrollPaneUI object that renders this component
See Also:
setUI(javax.swing.plaf.ScrollPaneUI)

setUI

public void setUI(ScrollPaneUI ui)
Sets the ScrollPaneUI object that provides the look and feel for this component.
Parameters:
ui - the ScrollPaneUI L&F object
See Also:
getUI()

updateUI

public void updateUI()
To be called when the default look and feel changes. Replaces the current ScrollPaneUI object with a version from the current default LookAndFeel.
Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI(), UIManager.getUI(javax.swing.JComponent)

getUIClassID

public String getUIClassID()
Returns the key used to look up the ScrollPaneUI class that provides the look and feel for JScrollPane.
Overrides:
getUIClassID in class JComponent
Returns:
"ScrollPaneUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

setLayout

public void setLayout(LayoutManager layout)
Sets the layout manager for this JScrollPane. This method overrides setLayout in java.awt.Container to ensure that only LayoutManagers which are subclasses of ScrollPaneLayout can be used in a JScrollPane.
Overrides:
setLayout in class Container
Parameters:
layout - the specified layout manager
Throws:
ClassCastException - if layout is not a ScrollPaneLayout
See Also:
Container.getLayout(), Container.setLayout(java.awt.LayoutManager)

isOpaque

public boolean isOpaque()
Returns true if this component paints every pixel in its range. (In other words, it does not have a transparent background or foreground.)
Overrides:
isOpaque in class JComponent
Returns:
The value of the opaque property
See Also:
JComponent.isOpaque()

isValidateRoot

public boolean isValidateRoot()
Calls to revalidate() on any descendant of this JScrollPane, e.g. the viewports view, will cause a request to be queued that will validate the JScrollPane and all its descendants.
Overrides:
isValidateRoot in class JComponent
Returns:
true
See Also:
JComponent.revalidate()

getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()
Returns the vertical scroll bar policy value.
Returns:
the vertical scrollbar policy
See Also:
setVerticalScrollBarPolicy(int)

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int policy)
Determines when the vertical scrollbar appears in the scrollpane. Legal values are:
  • JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
  • JScrollPane.VERTICAL_SCROLLBAR_NEVER
  • JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
See Also:
getVerticalScrollBarPolicy()

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()
Returns the horizontal scroll bar policy value.
Returns:
the horizontal scrollbar policy.
See Also:
setHorizontalScrollBarPolicy(int)

setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int policy)
Determines when the horizontal scrollbar appears in the scrollpane. The options are:
  • JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
  • JScrollPane.HORIZONTAL_SCROLLBAR_NEVER
  • JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS
See Also:
getHorizontalScrollBarPolicy()

getViewportBorder

public Border getViewportBorder()
Returns the value of the viewportBorder property.
Returns:
the Border object that surrounds the viewport
See Also:
setViewportBorder(javax.swing.border.Border)

setViewportBorder

public void setViewportBorder(Border viewportBorder)
Add a border around the viewport. Note that the border isn't set on the viewport directly, JViewport doesn't support the JComponent border property. Similarly setting the JScrollPanes viewport doesn't effect the viewportBorder property.

The default value of this property is computed by the look and feel implementation.

See Also:
getViewportBorder(), setViewport(javax.swing.JViewport)

getViewportBorderBounds

public Rectangle getViewportBorderBounds()
Returns the bounds of the viewport border.
Returns:
a Rectangle object specifying the viewport border

createHorizontalScrollBar

public JScrollBar createHorizontalScrollBar()
Used by ScrollPaneUI implementations to create the horizontal scrollbar. Returns a JScrollPane.ScrollBar by default. Subclasses may override this method to force ScrollPaneUI implementations to use a JScrollBar subclass.
Returns:
a JScrollBar with a horizontal orientation
See Also:
JScrollBar

getHorizontalScrollBar

public JScrollBar getHorizontalScrollBar()
Returns the horizontal scroll bar.
Returns:
the scrollbar that controls the viewports horizontal view position
See Also:
setHorizontalScrollBar(javax.swing.JScrollBar)

setHorizontalScrollBar

public void setHorizontalScrollBar(JScrollBar horizontalScrollBar)
Add the scrollbar that controls the viewports horizontal view position to the scrollpane. This is usually unneccessary, JScrollPane creates horizontal and vertical scrollbars by default.
See Also:
createHorizontalScrollBar(), getHorizontalScrollBar()

createVerticalScrollBar

public JScrollBar createVerticalScrollBar()
Used by ScrollPaneUI implementations to create the vertical scrollbar. Returns a JScrollPane.ScrollBar by default. Subclasses may override this method to force ScrollPaneUI implementations to use a JScrollBar subclass.
Returns:
a JScrollBar with a vertical orientation
See Also:
JScrollBar

getVerticalScrollBar

public JScrollBar getVerticalScrollBar()
Returns the vertical scroll bar.
Returns:
the scrollbar that controls the viewports vertical view position
See Also:
setVerticalScrollBar(javax.swing.JScrollBar)

setVerticalScrollBar

public void setVerticalScrollBar(JScrollBar verticalScrollBar)
Add the scrollbar that controls the viewports vertical view position to the scrollpane. This is usually unneccessary, JScrollPane creates vertical and vertical scrollbars by default.
See Also:
createVerticalScrollBar(), getVerticalScrollBar()

createViewport

protected JViewport createViewport()
Returns a new JViewport by default. Used to create the viewport (as needed) in setViewportView, setRowHeaderView, and setColumnHeaderView. Subclasses may override this method to return a subclass of JViewport.
Returns:
a JViewport

getViewport

public JViewport getViewport()
Returns the current JViewport.
Returns:
the JViewport currently in use
See Also:
setViewport(javax.swing.JViewport)

setViewport

public void setViewport(JViewport viewport)
Remove the old viewport (if there is one), force the viewPosition of the new viewport to be in the +x,+y quadrant, sync up the row and column headers (if there are any) with the new viewport, and finally sync the scrollbars and headers with the new viewport.

Most applications will find it more convenient to use setViewportView to add a viewport and a view to the scrollpane.

See Also:
createViewport(), getViewport(), setViewportView(java.awt.Component)

setViewportView

public void setViewportView(Component view)
Creates a viewport if neccessary and then sets its view. Applications that don't provide the view directly to the JScrollPane constructor should use this method to specify the scrollable child that's going to be displayed in the scrollpane, e.g.:
 JScrollPane scrollpane = new JScrollPane();
 scrollpane.setViewportView(myBigComponentToScroll);
 
Applications should not add children directly to the scrollpane.
Parameters:
view - the Component to add to the viewport
See Also:
setViewport(javax.swing.JViewport), JViewport.setView(java.awt.Component)

getRowHeader

public JViewport getRowHeader()
Returns the row header.
Returns:
the JViewport for the row header
See Also:
setRowHeader(javax.swing.JViewport)

setRowHeader

public void setRowHeader(JViewport rowHeader)
If an old rowHeader exists, remove it. If the new rowHeader isn't null, sync the y coordinate of the its viewPosition with the viewport (if there is one) and then add it to the ScrollPane.

Most applications will find it more convenient to use setRowHeaderView to add a row header component and its viewport to the scrollpane.

See Also:
getRowHeader(), setRowHeaderView(java.awt.Component)

setRowHeaderView

public void setRowHeaderView(Component view)
Creates a row-header viewport if neccessary, sets its view and then adds the row-header viewport to the scrollpane. For example:
 JScrollPane scrollpane = new JScrollPane();
 scrollpane.setViewportView(myBigComponentToScroll);
 scrollpane.setRowHeaderView(myBigComponentsRowHeader);
 
Parameters:
view - the Component to display as the row header
See Also:
setRowHeader(javax.swing.JViewport), JViewport.setView(java.awt.Component)

getColumnHeader

public JViewport getColumnHeader()
Returns the column header.
Returns:
a JViewport object for the column header
See Also:
setColumnHeader(javax.swing.JViewport)

setColumnHeader

public void setColumnHeader(JViewport columnHeader)
If an old columnHeader exists, remove it. If the new columnHeader isn't null, sync the x coordinate of the its viewPosition with the viewport (if there is one) and then add it to the ScrollPane.

Most applications will find it more convenient to use setRowHeaderView to add a row header component and its viewport to the scrollpane.

See Also:
getColumnHeader(), setColumnHeaderView(java.awt.Component)

setColumnHeaderView

public void setColumnHeaderView(Component view)
Creates a column-header viewport if neccessary, sets its view and then adds the column-header viewport to the scrollpane. For example:
 JScrollPane scrollpane = new JScrollPane();
 scrollpane.setViewportView(myBigComponentToScroll);
 scrollpane.setColumnHeaderView(myBigComponentsColumnHeader);
 
Parameters:
view - the Component to display as the column header
See Also:
setColumnHeader(javax.swing.JViewport), JViewport.setView(java.awt.Component)

getCorner

public Component getCorner(String key)
Returns the component at the specified corner. The key value specifying the corner is one of:
  • JScrollPane.LOWER_LEFT_CORNER
  • JScrollPane.LOWER_RIGHT_CORNER
  • JScrollPane.UPPER_LEFT_CORNER
  • JScrollPane.UPPER_RIGHT_CORNER
Returns:
the Component at the specified corner
See Also:
setCorner(java.lang.String, java.awt.Component)

setCorner

public void setCorner(String key,
                      Component corner)
Adds a child that will appear in one of the scroll panes corners, if there's room. For example with both scrollbars showing (on the right and bottom edges of the scrollpane) the lower left corner component will be shown in the space between ends of the two scrollbars. Legal values for the key are:
  • JScrollPane.LOWER_LEFT_CORNER
  • JScrollPane.LOWER_RIGHT_CORNER
  • JScrollPane.UPPER_LEFT_CORNER
  • JScrollPane.UPPER_RIGHT_CORNER

Although "corner" isn't doesn't match any beans property signature, PropertyChange events are generated with the property name set to the corner key.

Parameters:
key - identifies which corner the component will appear in
corner - any component

paramString

protected String paramString()
Returns a string representation of this JScrollPane. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Overrides:
paramString in class JComponent
Returns:
a string representation of this JScrollPane.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
the AccessibleContext of this JComponent

JavaTM 2 Platform
Standard Edition

Submit a bug or feature
Java, Java 2D, and JDBC are a trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.