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
-
cornerKeywords
- An array of constants that specify the corners
-
JScrollPane()
- Create an empty JScrollPane where both horizontal and vertical
scrollbars appear when needed.
-
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.
-
JScrollPane(Component, int, int)
- Create a JScrollPane that displays the contents of the specified
component using the specified scrollbar policies.
-
JScrollPane(int, int)
- Create an empty JScrollPane with specified scrollbar policies.
-
createHorizontalScrollBar()
- Used by ScrollPaneUI implementations to create the horizontal
scrollbar.
-
createVerticalScrollBar()
- Used by ScrollPaneUI implementations to create the vertical
scrollbar.
-
createViewport()
- Returns a new JViewport by default.
-
getAccessibleContext()
- Get the AccessibleContext associated with this JComponent
-
getColumnHeader()
- Returns the column-header viewport.
-
getCorner(String)
- Returns the _________________,
where the options for the key are:
- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
-
getHorizontalScrollBar()
- Returns the horizontal scroll bar currently in use.
-
getHorizontalScrollBarPolicy()
- Returns the horizontal scrollbar policy.
-
getRowHeader()
- Returns the row-header viewport.
-
getUI()
- Returns the L&F object that renders this component.
-
getUIClassID()
- Returns the name of the L&F class that renders this component.
-
getVerticalScrollBar()
- Returns the vertical scroll bar currently in use.
-
getVerticalScrollBarPolicy()
- Returns the vertical scrollbar policy.
-
getViewport()
- Returns the current JViewport.
-
getViewportBorder()
- Returns the value of the viewportBorder property.
-
isOpaque()
- Returns true if this component paints every pixel
in its range.
-
isValidateRoot()
-
Calls to revalidate() any descendant of this JScrollPane, e.g.
-
setColumnHeader(JViewport)
- Sets a column-header viewport
-
setColumnHeaderView(Component)
- Creates a column-header viewport if neccessary and then sets
its view.
-
setCorner(String, Component)
- Sets the _________________,
where the options for the key are:
- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
-
setHorizontalScrollBarPolicy(int)
-
-
setRowHeader(JViewport)
- Sets a row-header viewport.
-
setRowHeaderView(Component)
- Creates a row-header viewport if neccessary and then sets
its view.
-
setUI(ScrollPaneUI)
- Sets the L&F object that renders this component.
-
setVerticalScrollBarPolicy(int)
-
-
setViewport(JViewport)
- Sets the current JViewport.
-
setViewportBorder(Border)
- Add a border around the viewport.
-
setViewportView(Component)
- Creates a viewport if neccessary and then sets its view.
-
updateUI()
- Notification from the UIManager that the L&F has changed.
cornerKeywords
protected static final String cornerKeywords[]
- An array of constants that specify the corners
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:
- ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
- ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
- ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
- 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(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:
- ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
- ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
- ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
- ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
- 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.
getUI
public ScrollPaneUI getUI()
- Returns the L&F object that renders this component.
- Returns:
- the ScrollPaneUI object that renders this component
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
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 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:
- JScrollPane. ScrollBar
getVerticalScrollBar
public JScrollBar getVerticalScrollBar()
- Returns the vertical scroll bar currently in use.
- Returns:
- the JScrollBar currently used for vertical scrolling
- See Also:
- JScrollPane. 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(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(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(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 Component getCorner(String key)
- Returns the _________________,
where the options for the key are:
- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
- Parameters:
- key - a String specifying the corner
- Returns:
- the Component _________________
setCorner
public void setCorner(String key,
Component x)
- Sets the _________________,
where the options for the key are:
- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
- 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
- Returns:
- the AccessibleContext of this JComponent
- Overrides:
- getAccessibleContext in class JComponent
All Packages Class Hierarchy This Package Previous Next Index