|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JScrollPane
A specialized container that manages a viewport, optional vertical and horizontal scrollbars, and optional row and column heading viewports.
|
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.
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 FormInner 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 |
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 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.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected int verticalScrollBarPolicy
setVerticalScrollBarPolicy(int)
protected int horizontalScrollBarPolicy
setHorizontalScrollBarPolicy(int)
protected JViewport viewport
setViewport(javax.swing.JViewport)
protected JScrollBar verticalScrollBar
protected JScrollBar horizontalScrollBar
protected JViewport rowHeader
setRowHeader(javax.swing.JViewport)
protected JViewport columnHeader
setColumnHeader(javax.swing.JViewport)
protected Component lowerLeft
protected Component lowerRight
protected Component upperLeft
protected Component upperRight
Constructor Detail |
public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
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)
.view
- the Component to display in the scrollpanes viewportvsbPolicy
- an int that specifies the vertical scrollbar policyhsbPolicy
- an int that specifies the horizontal scrollbar policysetViewportView(java.awt.Component)
public JScrollPane(Component view)
view
- the Component to display in the scrollpanes viewportsetViewportView(java.awt.Component)
public JScrollPane(int vsbPolicy, int hsbPolicy)
setVerticalScrollBarPolicy(int)
and setHorizontalScrollBarPolicy(int)
.vsbPolicy
- an int that specifies the vertical scrollbar policyhsbPolicy
- an int that specifies the horizontal scrollbar policysetViewportView(java.awt.Component)
public JScrollPane()
Method Detail |
public ScrollPaneUI getUI()
setUI(javax.swing.plaf.ScrollPaneUI)
public void setUI(ScrollPaneUI ui)
ui
- the ScrollPaneUI L&F objectgetUI()
public void updateUI()
public String getUIClassID()
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public void setLayout(LayoutManager layout)
layout
- the specified layout managerContainer.getLayout()
,
Container.setLayout(java.awt.LayoutManager)
public boolean isOpaque()
JComponent.isOpaque()
public boolean isValidateRoot()
JComponent.revalidate()
public int getVerticalScrollBarPolicy()
setVerticalScrollBarPolicy(int)
public void setVerticalScrollBarPolicy(int policy)
getVerticalScrollBarPolicy()
public int getHorizontalScrollBarPolicy()
setHorizontalScrollBarPolicy(int)
public void setHorizontalScrollBarPolicy(int policy)
getHorizontalScrollBarPolicy()
public Border getViewportBorder()
setViewportBorder(javax.swing.border.Border)
public void setViewportBorder(Border viewportBorder)
The default value of this property is computed by the look and feel implementation.
public Rectangle getViewportBorderBounds()
public JScrollBar createHorizontalScrollBar()
JScrollBar
public JScrollBar getHorizontalScrollBar()
setHorizontalScrollBar(javax.swing.JScrollBar)
public void setHorizontalScrollBar(JScrollBar horizontalScrollBar)
public JScrollBar createVerticalScrollBar()
JScrollBar
public JScrollBar getVerticalScrollBar()
setVerticalScrollBar(javax.swing.JScrollBar)
public void setVerticalScrollBar(JScrollBar verticalScrollBar)
createVerticalScrollBar()
,
getVerticalScrollBar()
protected JViewport createViewport()
setViewportView
,
setRowHeaderView
, and setColumnHeaderView
.
Subclasses may override this method to return a subclass of JViewport.public JViewport getViewport()
setViewport(javax.swing.JViewport)
public void setViewport(JViewport viewport)
Most applications will find it more convenient to use setViewportView to add a viewport and a view to the scrollpane.
public void setViewportView(Component view)
JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll);Applications should not add children directly to the scrollpane.
view
- the Component to add to the viewportsetViewport(javax.swing.JViewport)
,
JViewport.setView(java.awt.Component)
public JViewport getRowHeader()
setRowHeader(javax.swing.JViewport)
public void setRowHeader(JViewport rowHeader)
Most applications will find it more convenient to use setRowHeaderView to add a row header component and its viewport to the scrollpane.
public void setRowHeaderView(Component view)
JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); scrollpane.setRowHeaderView(myBigComponentsRowHeader);
view
- the Component to display as the row headersetRowHeader(javax.swing.JViewport)
,
JViewport.setView(java.awt.Component)
public JViewport getColumnHeader()
setColumnHeader(javax.swing.JViewport)
public void setColumnHeader(JViewport columnHeader)
Most applications will find it more convenient to use setRowHeaderView to add a row header component and its viewport to the scrollpane.
public void setColumnHeaderView(Component view)
JScrollPane scrollpane = new JScrollPane(); scrollpane.setViewportView(myBigComponentToScroll); scrollpane.setColumnHeaderView(myBigComponentsColumnHeader);
view
- the Component to display as the column headersetColumnHeader(javax.swing.JViewport)
,
JViewport.setView(java.awt.Component)
public Component getCorner(String key)
key
value specifying the corner is one of:
setCorner(java.lang.String, java.awt.Component)
public void setCorner(String key, Component 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.
key
- identifies which corner the component will appear incorner
- any componentprotected String paramString()
null
.public AccessibleContext getAccessibleContext()
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |