All Packages  Class Hierarchy  This Package  Previous  Next  Index

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

Variable Index

 o cornerKeywords
An array of constants that specify the corners

Constructor Index

 o JScrollPane()
Create an empty JScrollPane where both horizontal and vertical scrollbars appear when needed.
 o JScrollPane(Component)
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.
 o JScrollPane(Component, int, int)
Create a JScrollPane that displays the contents of the specified component using the specified scrollbar policies.
 o JScrollPane(int, int)
Create an empty JScrollPane with specified scrollbar policies.

Method Index

 o createHorizontalScrollBar()
Used by ScrollPaneUI implementations to create the horizontal scrollbar.
 o createVerticalScrollBar()
Used by ScrollPaneUI implementations to create the vertical scrollbar.
 o createViewport()
Returns a new JViewport by default.
 o getAccessibleContext()
Get the AccessibleContext associated with this JComponent
 o getColumnHeader()
Returns the column-header viewport.
 o getCorner(String)
Returns the _________________, where the options for the key are:
 o getHorizontalScrollBar()
Returns the horizontal scroll bar currently in use.
 o getHorizontalScrollBarPolicy()
Returns the horizontal scrollbar policy.
 o getRowHeader()
Returns the row-header viewport.
 o getUI()
Returns the L&F object that renders this component.
 o getUIClassID()
Returns the name of the L&F class that renders this component.
 o getVerticalScrollBar()
Returns the vertical scroll bar currently in use.
 o getVerticalScrollBarPolicy()
Returns the vertical scrollbar policy.
 o getViewport()
Returns the current JViewport.
 o getViewportBorder()
Returns the value of the viewportBorder property.
 o isOpaque()
Returns true if this component paints every pixel in its range.
 o isValidateRoot()
Calls to revalidate() any descendant of this JScrollPane, e.g.
 o setColumnHeader(JViewport)
Sets a column-header viewport
 o setColumnHeaderView(Component)
Creates a column-header viewport if neccessary and then sets its view.
 o setCorner(String, Component)
Sets the _________________, where the options for the key are:
 o setHorizontalScrollBarPolicy(int)
 o setRowHeader(JViewport)
Sets a row-header viewport.
 o setRowHeaderView(Component)
Creates a row-header viewport if neccessary and then sets its view.
 o setUI(ScrollPaneUI)
Sets the L&F object that renders this component.
 o setVerticalScrollBarPolicy(int)
 o setViewport(JViewport)
Sets the current JViewport.
 o setViewportBorder(Border)
Add a border around the viewport.
 o setViewportView(Component)
Creates a viewport if neccessary and then sets its view.
 o updateUI()
Notification from the UIManager that the L&F has changed.

Variables

 o cornerKeywords
 protected static final String cornerKeywords[]
An array of constants that specify the corners

Constructors

 o JScrollPane
 public JScrollPane(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
 o 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
 o 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
 o JScrollPane
 public JScrollPane()
Create an empty JScrollPane where both horizontal and vertical scrollbars appear when needed.

Methods

 o getUI
 public ScrollPaneUI getUI()
Returns the L&F object that renders this component.

Returns:
the ScrollPaneUI object that renders this component
 o setUI
 public void setUI(ScrollPaneUI ui)
Sets the L&F object that renders this component.

Parameters:
ui - the ScrollPaneUI L&F object
See Also:
getUI
 o 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
 o getUIClassID
 public 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
 o getVerticalScrollBarPolicy
 public int getVerticalScrollBarPolicy()
Returns the vertical scrollbar policy.

Returns:
an int giving the policy
See Also:
setVerticalScrollBarPolicy
 o setVerticalScrollBarPolicy
 public void setVerticalScrollBarPolicy(int x)
 o getHorizontalScrollBarPolicy
 public int getHorizontalScrollBarPolicy()
Returns the horizontal scrollbar policy.

Returns:
an int giving the policy
See Also:
setHorizontalScrollBarPolicy
 o setHorizontalScrollBarPolicy
 public void setHorizontalScrollBarPolicy(int x)
 o getViewportBorder
 public Border getViewportBorder()
Returns the value of the viewportBorder property.

Returns:
the Border object that surrounds the viewport
See Also:
setViewportBorder
 o 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
 o 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
 o 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
 o getHorizontalScrollBar
 public JScrollBar getHorizontalScrollBar()
Returns the horizontal scroll bar currently in use.

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

Returns:
the JScrollBar currently used for vertical scrolling
See Also:
JScrollPane. ScrollBar
 o 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
 o getViewport
 public JViewport getViewport()
Returns the current JViewport.

Returns:
the JViewport currently in use
 o setViewport
 public void setViewport(JViewport x)
Sets the current JViewport.

Returns:
the JViewport to use
 o setViewportView
 public void setViewportView(Component view)
Creates a viewport if neccessary and then sets its view.

Parameters:
view - the Component to view
 o getRowHeader
 public JViewport getRowHeader()
Returns the row-header viewport.

Returns:
the JViewport for the row header
 o setRowHeader
 public void setRowHeader(JViewport x)
Sets a row-header viewport.

Parameters:
x - the JViewport to use for a row header
 o setRowHeaderView
 public void setRowHeaderView(Component view)
Creates a row-header viewport if neccessary and then sets its view.

Parameters:
view - the Component to display as the row header
 o getColumnHeader
 public JViewport getColumnHeader()
Returns the column-header viewport.

Returns:
the JViewport for the column header
 o setColumnHeader
 public void setColumnHeader(JViewport x)
Sets a column-header viewport

Parameters:
x - the JViewport to use for the column header
 o setColumnHeaderView
 public void setColumnHeaderView(Component view)
Creates a column-header viewport if neccessary and then sets its view.

Parameters:
view - the Component to display as the column header
 o getCorner
 public Component getCorner(String key)
Returns the _________________, where the options for the key are:

Parameters:
key - a String specifying the corner
Returns:
the Component _________________
 o setCorner
 public void setCorner(String key,
                       Component x)
Sets the _________________, where the options for the key are:

Parameters:
key - a String specifying the corner
x - the Component _________________
 o 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
 o 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
 o getAccessibleContext
 public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent

Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index