Overview | Package | Class | Tree | Deprecated | Index | Help Java Platform
1.1.7
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.sun.java.swing.JScrollPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--com.sun.java.swing.JComponent
                    |
                    +--com.sun.java.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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.

See Also:
JScrollBar, JViewport, setRowHeaderView, setColumnHeaderView, setCorner, setViewportBorder, Serialized Form

Inner Class Summary
JScrollPane.AccessibleJScrollPane
          The class used to obtain the accessible role for this object.
JScrollPane.ScrollBar
          By default JScrollPane creates scrollbars that are instances of this class.
 
Inner classes inherited from class com.sun.java.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
static java.lang.String[] cornerKeywords
          An array of constants that specify the corners
 
Fields inherited from class com.sun.java.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
 
Constructor Summary
JScrollPane(java.awt.Component view, int vsbPolicy, int hsbPolicy)
          Create a JScrollPane that displays the contents of the specified component using the specified scrollbar policies.
JScrollPane(java.awt.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(int vsbPolicy, int hsbPolicy)
          Create an empty JScrollPane with specified scrollbar policies.
JScrollPane()
          Create an empty JScrollPane where both horizontal and vertical scrollbars appear when needed.
 
Method Summary
JScrollBar createHorizontalScrollBar()
          Used by ScrollPaneUI implementations to create the horizontal scrollbar.
JScrollBar createVerticalScrollBar()
          Used by ScrollPaneUI implementations to create the vertical scrollbar.
JViewport createViewport()
          Returns a new JViewport by default.
AccessibleContext getAccessibleContext()
          Get the AccessibleContext associated with this JComponent
JViewport getColumnHeader()
          Returns the column-header viewport.
java.awt.Component getCorner(java.lang.String key)
          Returns the _________________, where the options for the key are:
  • ScrollPaneConstants.
JScrollBar getHorizontalScrollBar()
          Returns the horizontal scroll bar currently in use.
int getHorizontalScrollBarPolicy()
          Returns the horizontal scrollbar policy.
JViewport getRowHeader()
          Returns the row-header viewport.
java.lang.String getUIClassID()
          Returns the name of the L&F class that renders this component.
com.sun.java.swing.plaf.ScrollPaneUI getUI()
          Returns the L&F object that renders this component.
JScrollBar getVerticalScrollBar()
          Returns the vertical scroll bar currently in use.
int getVerticalScrollBarPolicy()
          Returns the vertical scrollbar policy.
Border getViewportBorder()
          Returns the value of the viewportBorder property.
JViewport getViewport()
          Returns the current JViewport.
boolean isOpaque()
          Returns true if this component paints every pixel in its range.
boolean isValidateRoot()
          Calls to revalidate() any descendant of this JScrollPane, e.g. the viewports view, will cause a request to be queued that will validate this JScrollPane and all its descendants.
void setColumnHeader(JViewport x)
          Sets a column-header viewport
void setColumnHeaderView(java.awt.Component view)
          Creates a column-header viewport if neccessary and then sets its view.
void setCorner(java.lang.String key, java.awt.Component x)
          Sets the _________________, where the options for the key are:
  • ScrollPaneConstants.
void setHorizontalScrollBarPolicy(int x)
           
void setRowHeader(JViewport x)
          Sets a row-header viewport.
void setRowHeaderView(java.awt.Component view)
          Creates a row-header viewport if neccessary and then sets its view.
void setUI(com.sun.java.swing.plaf.ScrollPaneUI ui)
          Sets the L&F object that renders this component.
void setVerticalScrollBarPolicy(int x)
           
void setViewportBorder(Border viewportBorder)
          Add a border around the viewport.
void setViewport(JViewport x)
          Sets the current JViewport.
void setViewportView(java.awt.Component view)
          Creates a viewport if neccessary and then sets its view.
void updateUI()
          Notification from the UIManager that the L&F has changed.
 
Methods inherited from class com.sun.java.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paint, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setBounds, setDebugGraphicsOptions, setDoubleBuffered, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

cornerKeywords

protected static final java.lang.String[] cornerKeywords
An array of constants that specify the corners
Constructor Detail

JScrollPane

public JScrollPane(java.awt.Component view,
                   int vsbPolicy,
                   int hsbPolicy)
Create a JScrollPane that displays the contents of the specified component using the specified scrollbar policies. The scrollbar policies determine the circumstances under which the scrollbars are displayed:
Parameters:
view - the Component to display
vsbPolicy - an int specifying the vertical scrollbar policy
hsbPolicy - an int specifying the horizontal scrollbar policy

JScrollPane

public JScrollPane(java.awt.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

JScrollPane

public JScrollPane(int vsbPolicy,
                   int hsbPolicy)
Create an empty JScrollPane with specified scrollbar policies. The scrollbar policies determine the circumstances under which the scrollbars are displayed:
Parameters:
vsbPolicy - an int specifying the vertical scrollbar policy
hsbPolicy - an int specifying the horizontal scrollbar policy

JScrollPane

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

getUI

public com.sun.java.swing.plaf.ScrollPaneUI getUI()
Returns the L&F object that renders this component.
Returns:
the ScrollPaneUI object that renders this component

setUI

public void setUI(com.sun.java.swing.plaf.ScrollPaneUI ui)
Sets the L&F object that renders this component.
Parameters:
ui - the ScrollPaneUI L&F object
See Also:
getUI

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
Overrides:
updateUI in class JComponent
See Also:
updateUI

getUIClassID

public java.lang.String getUIClassID()
Returns the name of the L&F class that renders this component.
Returns:
"ScrollPaneUI"
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI

getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()
Returns the vertical scrollbar policy.
Returns:
an int giving the policy
See Also:
setVerticalScrollBarPolicy

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int x)

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()
Returns the horizontal scrollbar policy.
Returns:
an int giving the policy
See Also:
setHorizontalScrollBarPolicy

setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int x)

getViewportBorder

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

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.

This is a JavaBeans bound property.

See Also:
getViewportBorder, setViewport

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

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

getHorizontalScrollBar

public JScrollBar getHorizontalScrollBar()
Returns the horizontal scroll bar currently in use.
Returns:
the JScrollBar currently used for horizontal scrolling
See Also:
ScrollBar

getVerticalScrollBar

public JScrollBar getVerticalScrollBar()
Returns the vertical scroll bar currently in use.
Returns:
the JScrollBar currently used for vertical scrolling
See Also:
ScrollBar

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

setViewport

public void setViewport(JViewport x)
Sets the current JViewport.
Returns:
the JViewport to use

setViewportView

public void setViewportView(java.awt.Component view)
Creates a viewport if neccessary and then sets its view.
Parameters:
view - the Component to view

getRowHeader

public JViewport getRowHeader()
Returns the row-header viewport.
Returns:
the JViewport for the row header

setRowHeader

public void setRowHeader(JViewport x)
Sets a row-header viewport.
Parameters:
x - the JViewport to use for a row header

setRowHeaderView

public void setRowHeaderView(java.awt.Component view)
Creates a row-header viewport if neccessary and then sets its view.
Parameters:
view - the Component to display as the row header

getColumnHeader

public JViewport getColumnHeader()
Returns the column-header viewport.
Returns:
the JViewport for the column header

setColumnHeader

public void setColumnHeader(JViewport x)
Sets a column-header viewport
Parameters:
x - the JViewport to use for the column header

setColumnHeaderView

public void setColumnHeaderView(java.awt.Component view)
Creates a column-header viewport if neccessary and then sets its view.
Parameters:
view - the Component to display as the column header

getCorner

public java.awt.Component getCorner(java.lang.String key)
Returns the _________________, where the options for the key are:
Parameters:
key - a String specifying the corner
Returns:
the Component _________________

setCorner

public void setCorner(java.lang.String key,
                      java.awt.Component x)
Sets the _________________, where the options for the key are:
Parameters:
key - a String specifying the corner
x - the Component _________________

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.)
Returns:
The value of the opaque property
Overrides:
isOpaque in class JComponent
See Also:
isOpaque

isValidateRoot

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

getAccessibleContext

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

Overview | Package | Class | Tree | Deprecated | Index | Help Java Platform
1.1.7
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug or feature
Submit comments/suggestions about javadoc
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.