javax.swing
Class JScrollPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JScrollPane
All Implemented Interfaces:
Accessible, java.awt.image.ImageObserver, MenuContainer, ScrollPaneConstants, Serializable

public class JScrollPane
extends JComponent
implements ScrollPaneConstants, Accessible

Safe:

See Also:
Serialized Form

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.
private static String uiClassID
           
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 scrollpane's viewport child.
private  javax.swing.border.Border viewportBorder
           
private  boolean wheelScrollState
           
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, listenerList, paintingChild, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
 
Constructor Summary
JScrollPane()
          Enabled: Creates an empty (no viewport view) JScrollPane where both horizontal and vertical scrollbars appear when needed.
JScrollPane(Component view)
          Enabled: Creates 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)
          Enabled: Creates 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)
          Enabled: Creates an empty (no viewport view) JScrollPane with specified scrollbar policies.
 
Method Summary
 JScrollBar createHorizontalScrollBar()
          Suppressed: Returns a JScrollPane.ScrollBar by default.
 JScrollBar createVerticalScrollBar()
          Suppressed: Returns a JScrollPane.ScrollBar by default.
protected  JViewport createViewport()
          Returns a new JViewport by default.
 AccessibleContext getAccessibleContext()
          Suppressed: Gets the AccessibleContext associated with this JScrollPane.
 JViewport getColumnHeader()
          Enabled: Returns the column header.
 Component getCorner(String key)
          Enabled: Returns the component at the specified corner.
 JScrollBar getHorizontalScrollBar()
          Enabled: Returns the horizontal scroll bar that controls the viewport's horizontal view position.
 int getHorizontalScrollBarPolicy()
          Enabled: Returns the horizontal scroll bar policy value.
 JViewport getRowHeader()
          Enabled: Returns the row header.
 javax.swing.plaf.ScrollPaneUI getUI()
          Suppressed: Returns the look and feel (L&F) object that renders this component.
 String getUIClassID()
          Suppressed: Returns the suffix used to construct the name of the L&F class used to render this component.
 JScrollBar getVerticalScrollBar()
          Enabled: Returns the vertical scroll bar that controls the viewports vertical view position.
 int getVerticalScrollBarPolicy()
          Enabled: Returns the vertical scroll bar policy value.
 JViewport getViewport()
          Enabled: Returns the current JViewport.
 javax.swing.border.Border getViewportBorder()
          Enabled: Returns the Border object that surrounds the viewport.
 Rectangle getViewportBorderBounds()
          Enabled: Returns the bounds of the viewport's border.
 boolean isValidateRoot()
          Enabled: Calls revalidate on any descendant of this JScrollPane.
 boolean isWheelScrollingEnabled()
          Enabled: Indicates whether or not scrolling will take place in response to the mouse wheel.
protected  String paramString()
          Returns a string representation of this JScrollPane.
 void setColumnHeader(JViewport columnHeader)
          Enabled: Removes the old columnHeader, if it exists.
 void setColumnHeaderView(Component view)
          Enabled: Creates a column-header viewport if necessary, sets its view, and then adds the column-header viewport to the scrollpane.
 void setComponentOrientation(ComponentOrientation co)
          Enabled: Sets the orientation for the vertical and horizontal scrollbars as determined by the ComponentOrientation argument.
 void setCorner(String key, Component corner)
          Enabled: Adds a child that will appear in one of the scroll panes corners, if there's room.
 void setHorizontalScrollBar(JScrollBar horizontalScrollBar)
          Suppressed: Adds the scrollbar that controls the viewport's horizontal view position to the scrollpane.
 void setHorizontalScrollBarPolicy(int policy)
          Enabled: Determines when the horizontal scrollbar appears in the scrollpane.
 void setLayout(LayoutManager layout)
          Enabled: Sets the layout manager for this JScrollPane.
 void setRowHeader(JViewport rowHeader)
          Enabled: Removes the old rowHeader, if it exists.
 void setRowHeaderView(Component view)
          Enabled: Creates a row-header viewport if necessary, sets its view and then adds the row-header viewport to the scrollpane.
 void setUI(javax.swing.plaf.ScrollPaneUI ui)
          Suppressed: Sets the ScrollPaneUI object that provides the look and feel (L&F) for this component.
 void setVerticalScrollBar(JScrollBar verticalScrollBar)
          Suppressed: Adds the scrollbar that controls the viewports vertical view position to the scrollpane.
 void setVerticalScrollBarPolicy(int policy)
          Enabled: Determines when the vertical scrollbar appears in the scrollpane.
 void setViewport(JViewport viewport)
          Enabled: Removes the old viewport (if there is one); forces the viewPosition of the new viewport to be in the +x,+y quadrant; syncs up the row and column headers (if there are any) with the new viewport; and finally syncs the scrollbars and headers with the new viewport.
 void setViewportBorder(javax.swing.border.Border viewportBorder)
          Enabled: Adds a border around the viewport.
 void setViewportView(Component view)
          Enabled: Creates a viewport if necessary and then sets its view.
 void setWheelScrollingEnabled(boolean handleWheel)
          Enabled: Enables/disables scrolling in response to movement of the mouse wheel.
 void updateUI()
          Suppressed: Replaces the current ScrollPaneUI object with a version from the current default look and feel.
private  void writeObject(ObjectOutputStream s)
          See readObject and writeObject in JComponent for more information about serialization in Swing.
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, alwaysOnTop, checkIfChildObscuredBySibling, componentInputMapChanged, computeVisibleRect, computeVisibleRect, compWriteObjectNotify, contains, createToolTip, disable, enable, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getCreatedDoubleBuffer, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getManagingFocusBackwardTraversalKeys, getManagingFocusForwardTraversalKeys, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getWriteObjCounter, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setCreatedDoubleBuffer, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, setWriteObjCounter, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, get, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, size, transferFocusBackward, 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, 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, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, toString, transferFocus, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

viewportBorder

private javax.swing.border.Border viewportBorder

uiClassID

private static final String uiClassID
See Also:
getUIClassID(), JComponent.readObject(java.io.ObjectInputStream)

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 scrollpane's 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)

wheelScrollState

private boolean wheelScrollState
Constructor Detail

JScrollPane

public JScrollPane(Component view,
                   int vsbPolicy,
                   int hsbPolicy)
Enabled: Creates 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, For example, if vsbPolicy is VERTICAL_SCROLLBAR_AS_NEEDED then the vertical scrollbar only appears if the view doesn't fit vertically. The available policy settings are listed at setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).

Parameters:
view - the component to display in the scrollpanes viewport
vsbPolicy - an integer that specifies the vertical scrollbar policy
hsbPolicy - an integer that specifies the horizontal scrollbar policy
See Also:
setViewportView(java.awt.Component)

JScrollPane

public JScrollPane(Component view)
Enabled: Creates 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 scrollpane's viewport
See Also:
setViewportView(java.awt.Component)

JScrollPane

public JScrollPane(int vsbPolicy,
                   int hsbPolicy)
Enabled: Creates an empty (no viewport view) JScrollPane with specified scrollbar policies. The available policy settings are listed at setVerticalScrollBarPolicy(int) and setHorizontalScrollBarPolicy(int).

Parameters:
vsbPolicy - an integer that specifies the vertical scrollbar policy
hsbPolicy - an integer that specifies the horizontal scrollbar policy
See Also:
setViewportView(java.awt.Component)

JScrollPane

public JScrollPane()
Enabled: Creates an empty (no viewport view) JScrollPane where both horizontal and vertical scrollbars appear when needed.

Method Detail

getUI

public javax.swing.plaf.ScrollPaneUI getUI()
Suppressed: Returns the look and feel (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(javax.swing.plaf.ScrollPaneUI ui)
Suppressed: Sets the ScrollPaneUI object that provides the look and feel (L&F) for this component.

Parameters:
ui - the ScrollPaneUI L&F object
See Also:
getUI()

updateUI

public void updateUI()
Suppressed: Replaces the current ScrollPaneUI object with a version from the current default look and feel. To be called when the default look and feel changes.

Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI(), UIManager.getUI(javax.swing.JComponent)

getUIClassID

public String getUIClassID()
Suppressed: Returns the suffix used to construct the name of the L&F class used to render this component.

Overrides:
getUIClassID in class JComponent
Returns:
the string "ScrollPaneUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

setLayout

public void setLayout(LayoutManager layout)
Enabled: 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. If layout is non-null, this will invoke syncWithScrollPane on it.

Overrides:
setLayout in class Container
Parameters:
layout - the specified layout manager
See Also:
java.awt.Container#getLayout, java.awt.Container#setLayout

isValidateRoot

public boolean isValidateRoot()
Enabled: Calls revalidate on any descendant of this JScrollPane. For example, the viewport's 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()
Enabled: Returns the vertical scroll bar policy value.

Returns:
the verticalScrollBarPolicy property
See Also:
setVerticalScrollBarPolicy(int)

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int policy)
Enabled: Determines when the vertical scrollbar appears in the scrollpane. Legal values are:

Parameters:
policy - one of the three values listed above
See Also:
getVerticalScrollBarPolicy()

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()
Enabled: Returns the horizontal scroll bar policy value.

Returns:
the horizontalScrollBarPolicy property
See Also:
setHorizontalScrollBarPolicy(int)

setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int policy)
Enabled: Determines when the horizontal scrollbar appears in the scrollpane. The options are:

Parameters:
policy - one of the three values listed above
See Also:
getHorizontalScrollBarPolicy()

getViewportBorder

public javax.swing.border.Border getViewportBorder()
Enabled: Returns the Border object that surrounds the viewport.

Returns:
the viewportBorder property
See Also:
setViewportBorder(javax.swing.border.Border)

setViewportBorder

public void setViewportBorder(javax.swing.border.Border viewportBorder)
Enabled: Adds 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 affect the viewportBorder property.

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

Parameters:
viewportBorder - the border to be added
See Also:
getViewportBorder(), setViewport(javax.swing.JViewport)

getViewportBorderBounds

public Rectangle getViewportBorderBounds()
Enabled: Returns the bounds of the viewport's border.

Returns:
a Rectangle object specifying the viewport border

createHorizontalScrollBar

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

Returns:
a JScrollBar with a horizontal orientation
See Also:
JScrollBar

getHorizontalScrollBar

public JScrollBar getHorizontalScrollBar()
Enabled: Returns the horizontal scroll bar that controls the viewport's horizontal view position.

Returns:
the horizontalScrollBar property
See Also:
setHorizontalScrollBar(javax.swing.JScrollBar)

setHorizontalScrollBar

public void setHorizontalScrollBar(JScrollBar horizontalScrollBar)
Suppressed: Adds the scrollbar that controls the viewport's horizontal view position to the scrollpane. This is usually unnecessary, as JScrollPane creates horizontal and vertical scrollbars by default.

Parameters:
horizontalScrollBar - the horizontal scrollbar to be added
See Also:
createHorizontalScrollBar(), getHorizontalScrollBar()

createVerticalScrollBar

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

Returns:
a JScrollBar with a vertical orientation
See Also:
JScrollBar

getVerticalScrollBar

public JScrollBar getVerticalScrollBar()
Enabled: Returns the vertical scroll bar that controls the viewports vertical view position.

Returns:
the verticalScrollBar property
See Also:
setVerticalScrollBar(javax.swing.JScrollBar)

setVerticalScrollBar

public void setVerticalScrollBar(JScrollBar verticalScrollBar)
Suppressed: Adds the scrollbar that controls the viewports vertical view position to the scrollpane. This is usually unnecessary, as JScrollPane creates vertical and horizontal scrollbars by default.

Parameters:
verticalScrollBar - the new vertical scrollbar to be added
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 new JViewport

getViewport

public JViewport getViewport()
Enabled: Returns the current JViewport.

Returns:
the viewport property
See Also:
setViewport(javax.swing.JViewport)

setViewport

public void setViewport(JViewport viewport)
Enabled: Removes the old viewport (if there is one); forces the viewPosition of the new viewport to be in the +x,+y quadrant; syncs up the row and column headers (if there are any) with the new viewport; and finally syncs 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.

Parameters:
viewport - the new viewport to be used; if viewport is null, the old viewport is still removed and the new viewport is set to null
See Also:
createViewport(), getViewport(), setViewportView(java.awt.Component)

setViewportView

public void setViewportView(Component view)
Enabled: Creates a viewport if necessary 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. For example:
 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()
Enabled: Returns the row header.

Returns:
the rowHeader property
See Also:
setRowHeader(javax.swing.JViewport)

setRowHeader

public void setRowHeader(JViewport rowHeader)
Enabled: Removes the old rowHeader, if it exists. If the new rowHeader isn't null, syncs the y coordinate of its viewPosition with the viewport (if there is one) and then adds 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.

Parameters:
rowHeader - the new row header to be used; if null the old row header is still removed and the new rowHeader is set to null
See Also:
getRowHeader(), setRowHeaderView(java.awt.Component)

setRowHeaderView

public void setRowHeaderView(Component view)
Enabled: Creates a row-header viewport if necessary, 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()
Enabled: Returns the column header.

Returns:
the columnHeader property
See Also:
setColumnHeader(javax.swing.JViewport)

setColumnHeader

public void setColumnHeader(JViewport columnHeader)
Enabled: Removes the old columnHeader, if it exists. 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)
Enabled: Creates a column-header viewport if necessary, 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)
Enabled: Returns the component at the specified corner. The key value specifying the corner is one of:

Parameters:
key - one of the values as shown above
Returns:
one of the components listed below or null if key is invalid:
  • lowerLeft
  • lowerRight
  • upperLeft
  • upperRight
See Also:
setCorner(java.lang.String, java.awt.Component)

setCorner

public void setCorner(String key,
                      Component corner)
Enabled: 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:

Although "corner" 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 - one of the following components:
  • lowerLeft
  • lowerRight
  • upperLeft
  • upperRight

setComponentOrientation

public void setComponentOrientation(ComponentOrientation co)
Enabled: Sets the orientation for the vertical and horizontal scrollbars as determined by the ComponentOrientation argument.

Overrides:
setComponentOrientation in class Component
Parameters:
co - one of the following values:
  • java.awt.ComponentOrientation.LEFT_TO_RIGHT
  • java.awt.ComponentOrientation.RIGHT_TO_LEFT
  • java.awt.ComponentOrientation.UNKNOWN
See Also:
java.awt.ComponentOrientation

isWheelScrollingEnabled

public boolean isWheelScrollingEnabled()
Enabled: Indicates whether or not scrolling will take place in response to the mouse wheel. Wheel scrolling is enabled by default.

Since:
1.4
See Also:
setWheelScrollingEnabled(boolean)

setWheelScrollingEnabled

public void setWheelScrollingEnabled(boolean handleWheel)
Enabled: Enables/disables scrolling in response to movement of the mouse wheel. Wheel scrolling is enabled by default.

Parameters:
handleWheel - true if scrolling should be done automatically for a MouseWheelEvent, false otherwise.
Since:
1.4
See Also:
isWheelScrollingEnabled(), java.awt.event.MouseWheelEvent, java.awt.event.MouseWheelListener

writeObject

private void writeObject(ObjectOutputStream s)
                  throws IOException
See readObject and writeObject in JComponent for more information about serialization in Swing.

Parameters:
s - the ObjectOutputStream in which to write
IOException

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()
Suppressed: Gets the AccessibleContext associated with this JScrollPane. For scroll panes, the AccessibleContext takes the form of an AccessibleJScrollPane. A new AccessibleJScrollPane instance is created if necessary.

Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent
Returns:
an AccessibleJScrollPane that serves as the AccessibleContext of this JScrollPane


comments?