
xy.reflect.ui.resource.jdk-apidocs.javax.swing.JScrollPane.html Maven / Gradle / Ivy
Show all versions of reflection-ui Show documentation
JScrollPane (Java Platform SE 6)
Overview
Package
Class
Use
Tree
Deprecated
Index
Help
Java™ Platform
Standard Ed. 6
PREV CLASS
NEXT CLASS
FRAMES
NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD
DETAIL: FIELD | CONSTR | METHOD
javax.swing
Class JScrollPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JScrollPane
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants
public class JScrollPane
- extends JComponent
- implements ScrollPaneConstants, Accessible
Provides a scrollable view of a lightweight component.
A JScrollPane
manages a viewport, optional
vertical and horizontal scroll bars, and optional row and
column heading viewports.
You can find task-oriented documentation of JScrollPane
in
How to Use Scroll Panes,
a section in The Java Tutorial. Note that
JScrollPane
does not support heavyweight components.
|
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 JScrollBar
s,
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.
Where two scroll bars meet, the row header meets the column header, or a scroll bar meets one of the headers, both components stop short of the corner, leaving a rectangular space which is, by default, empty. These spaces can potentially exist in any number of the four corners. In the previous diagram, the top right space is present and identified by the label "corner component".
Any number of these empty spaces can be replaced by using the
setCorner
method to add a component to a particular corner.
(Note: The same component cannot be added to multiple corners.)
This is useful if there's
some extra decoration or function you'd like to add to the scroll pane.
The size of each corner component is entirely determined by the size of the
headers and/or scroll bars that surround it.
A corner component will only be visible if there is an empty space in that
corner for it to exist in. For example, consider a component set into the
top right corner of a scroll pane with a column header. If the scroll pane's
vertical scrollbar is not present, perhaps because the view component hasn't
grown large enough to require it, then the corner component will not be
shown (since there is no empty space in that corner created by the meeting
of the header and vertical scroll bar). Forcing the scroll bar to always be
shown, using
setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_ALWAYS)
,
will ensure that the space for the corner component always exists.
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
.)
A common operation to want to do is to set the background color that will
be used if the main viewport view is smaller than the viewport, or is
not opaque. This can be accomplished by setting the background color
of the viewport, via scrollPane.getViewport().setBackground()
.
The reason for setting the color of the viewport and not the scrollpane
is that by default JViewport
is opaque
which, among other things, means it will completely fill
in its background using its background color. Therefore when
JScrollPane
draws its background the viewport will
usually draw over it.
By default JScrollPane
uses ScrollPaneLayout
to handle the layout of its child Components. ScrollPaneLayout
determines the size to make the viewport view in one of two ways:
- If the view implements
Scrollable
a combination ofgetPreferredScrollableViewportSize
,getScrollableTracksViewportWidth
andgetScrollableTracksViewportHeight
is used, otherwise getPreferredSize
is used.
Warning: Swing is not thread safe. For more information see Swing's Threading Policy.
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. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans
package.
Please see XMLEncoder
.
- See Also:
JScrollBar
,JViewport
,ScrollPaneLayout
,Scrollable
,Component.getPreferredSize()
,setViewportView(java.awt.Component)
,setRowHeaderView(java.awt.Component)
,setColumnHeaderView(java.awt.Component)
,setCorner(java.lang.String, java.awt.Component)
,setViewportBorder(javax.swing.border.Border)
Nested Class Summary | |
---|---|
protected class |
JScrollPane.AccessibleJScrollPane
This class implements accessibility support for the JScrollPane class. |
protected class |
JScrollPane.ScrollBar
By default JScrollPane creates scrollbars
that are instances
of this class. |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
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 scrollpane's 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 |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JScrollPane()
Creates an empty (no viewport view) JScrollPane
where both horizontal and vertical scrollbars appear when needed. |
|
JScrollPane(Component view)
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)
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)
Creates an empty (no viewport view) JScrollPane
with specified
scrollbar policies. |
Method Summary | |
---|---|
JScrollBar |
createHorizontalScrollBar()
Returns a JScrollPane.ScrollBar by default. |
JScrollBar |
createVerticalScrollBar()
Returns a JScrollPane.ScrollBar by default. |
protected JViewport |
createViewport()
Returns a new JViewport by default. |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JScrollPane. |
JViewport |
getColumnHeader()
Returns the column header. |
Component |
getCorner(String key)
Returns the component at the specified corner. |
JScrollBar |
getHorizontalScrollBar()
Returns the horizontal scroll bar that controls the viewport's horizontal view position. |
int |
getHorizontalScrollBarPolicy()
Returns the horizontal scroll bar policy value. |
JViewport |
getRowHeader()
Returns the row header. |
ScrollPaneUI |
getUI()
Returns the look and feel (L&F) object that renders this component. |
String |
getUIClassID()
Returns the suffix used to construct the name of the L&F class used to render this component. |
JScrollBar |
getVerticalScrollBar()
Returns the vertical scroll bar that controls the viewports vertical view position. |
int |
getVerticalScrollBarPolicy()
Returns the vertical scroll bar policy value. |
JViewport |
getViewport()
Returns the current JViewport . |
Border |
getViewportBorder()
Returns the Border object that surrounds the viewport. |
Rectangle |
getViewportBorderBounds()
Returns the bounds of the viewport's border. |
boolean |
isValidateRoot()
Overridden to return true so that any calls to revalidate
on any descendants of this JScrollPane will cause the
entire tree beginning with this JScrollPane to be
validated. |
boolean |
isWheelScrollingEnabled()
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)
Removes the old columnHeader, if it exists; if the new columnHeader isn't null , syncs the x coordinate of its viewPosition
with the viewport (if there is one) and then adds it to the scroll pane. |
void |
setColumnHeaderView(Component view)
Creates a column-header viewport if necessary, sets its view, and then adds the column-header viewport to the scrollpane. |
void |
setComponentOrientation(ComponentOrientation co)
Sets the orientation for the vertical and horizontal scrollbars as determined by the ComponentOrientation argument. |
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)
Adds the scrollbar that controls the viewport's 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)
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 scroll pane. |
void |
setRowHeaderView(Component view)
Creates a row-header viewport if necessary, 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 (L&F) for this component. |
void |
setVerticalScrollBar(JScrollBar verticalScrollBar)
Adds 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)
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(Border viewportBorder)
Adds a border around the viewport. |
void |
setViewportView(Component view)
Creates a viewport if necessary and then sets its view. |
void |
setWheelScrollingEnabled(boolean handleWheel)
Enables/disables scrolling in response to movement of the mouse wheel. |
void |
updateUI()
Replaces the current ScrollPaneUI object with a version
from the current default look and feel. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
verticalScrollBarPolicy
protected int verticalScrollBarPolicy
- The display policy for the vertical scrollbar.
The default is
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
.- See Also:
setVerticalScrollBarPolicy(int)
horizontalScrollBarPolicy
protected int horizontalScrollBarPolicy
- The display policy for the horizontal scrollbar.
The default is
ScrollPaneConstants.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
.
horizontalScrollBar
protected JScrollBar horizontalScrollBar
- The scrollpane's horizontal scrollbar child.
Default is a
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
.
lowerLeft
protected Component lowerLeft
- The component to display in the lower left corner.
Default is
null
.
lowerRight
protected Component lowerRight
- The component to display in the lower right corner.
Default is
null
.
upperLeft
protected Component upperLeft
- The component to display in the upper left corner.
Default is
null
.
upperRight
protected Component upperRight
- The component to display in the upper right corner.
Default is
null
.
Constructor Detail |
---|
JScrollPane
public JScrollPane(Component view, int vsbPolicy, int hsbPolicy)
- 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, ifvsbPolicy
isVERTICAL_SCROLLBAR_AS_NEEDED
then the vertical scrollbar only appears if the view doesn't fit vertically. The available policy settings are listed atsetVerticalScrollBarPolicy(int)
andsetHorizontalScrollBarPolicy(int)
.- Parameters:
view
- the component to display in the scrollpanes viewportvsbPolicy
- an integer that specifies the vertical scrollbar policyhsbPolicy
- an integer that specifies the horizontal scrollbar policy- See Also:
setViewportView(java.awt.Component)
JScrollPane
public JScrollPane(Component view)
- 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)
- Creates an empty (no viewport view)
JScrollPane
with specified scrollbar policies. The available policy settings are listed atsetVerticalScrollBarPolicy(int)
andsetHorizontalScrollBarPolicy(int)
.- Parameters:
vsbPolicy
- an integer that specifies the vertical scrollbar policyhsbPolicy
- an integer that specifies the horizontal scrollbar policy- See Also:
setViewportView(java.awt.Component)
JScrollPane
public JScrollPane()
- Creates an empty (no viewport view)
JScrollPane
where both horizontal and vertical scrollbars appear when needed.
Method Detail |
---|
getUI
public ScrollPaneUI getUI()
- 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(ScrollPaneUI ui)
- Sets the
ScrollPaneUI
object that provides the look and feel (L&F) for this component.- Parameters:
ui
- theScrollPaneUI
L&F object- See Also:
getUI()
updateUI
public void updateUI()
- 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 classJComponent
getUIClassID
public String getUIClassID()
- Returns the suffix used to construct the name of the L&F class used to
render this component.
- Overrides:
getUIClassID
in classJComponent
- Returns:
- the string "ScrollPaneUI"
- See Also:
JComponent.getUIClassID()
,UIDefaults.getUI(javax.swing.JComponent)
setLayout
public void setLayout(LayoutManager layout)
- Sets the layout manager for this
JScrollPane
. This method overridessetLayout
injava.awt.Container
to ensure that onlyLayoutManager
s which are subclasses ofScrollPaneLayout
can be used in aJScrollPane
. Iflayout
is non-null, this will invokesyncWithScrollPane
on it.- Parameters:
layout
- the specified layout manager- Throws:
ClassCastException
- if layout is not aScrollPaneLayout
- See Also:
Container.getLayout()
,Container.setLayout(java.awt.LayoutManager)
isValidateRoot
public boolean isValidateRoot()
- Overridden to return true so that any calls to
revalidate
on any descendants of thisJScrollPane
will cause the entire tree beginning with thisJScrollPane
to be validated.- Overrides:
isValidateRoot
in classJComponent
- Returns:
- true
- See Also:
Container.validate()
,JComponent.revalidate()
,JComponent.isValidateRoot()
getVerticalScrollBarPolicy
public int getVerticalScrollBarPolicy()
- Returns the vertical scroll bar policy value.
- Returns:
- the
verticalScrollBarPolicy
property - See Also:
setVerticalScrollBarPolicy(int)
setVerticalScrollBarPolicy
public void setVerticalScrollBarPolicy(int policy)
- Determines when the vertical scrollbar appears in the scrollpane.
Legal values are:
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
- Parameters:
policy
- one of the three values listed above- Throws:
IllegalArgumentException
- ifpolicy
is not one of the legal values shown above- See Also:
getVerticalScrollBarPolicy()
getHorizontalScrollBarPolicy
public int getHorizontalScrollBarPolicy()
- Returns the horizontal scroll bar policy value.
- Returns:
- the
horizontalScrollBarPolicy
property - See Also:
setHorizontalScrollBarPolicy(int)
setHorizontalScrollBarPolicy
public void setHorizontalScrollBarPolicy(int policy)
- Determines when the horizontal scrollbar appears in the scrollpane.
The options are:
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS
- Parameters:
policy
- one of the three values listed above- Throws:
IllegalArgumentException
- ifpolicy
is not one of the legal values shown above- See Also:
getHorizontalScrollBarPolicy()
getViewportBorder
public Border getViewportBorder()
- Returns the
Border
object that surrounds the viewport.- Returns:
- the
viewportBorder
property - See Also:
setViewportBorder(javax.swing.border.Border)
setViewportBorder
public void setViewportBorder(Border viewportBorder)
- Adds a border around the viewport. Note that the border isn't
set on the viewport directly,
JViewport
doesn't support theJComponent
border property. Similarly setting theJScrollPane
s viewport doesn't affect theviewportBorder
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()
- Returns the bounds of the viewport's border.
- Returns:
- a
Rectangle
object specifying the viewport border
createHorizontalScrollBar
public JScrollBar createHorizontalScrollBar()
- Returns a
JScrollPane.ScrollBar
by default. Subclasses may override this method to forceScrollPaneUI
implementations to use aJScrollBar
subclass. Used byScrollPaneUI
implementations to create the horizontal scrollbar.- Returns:
- a
JScrollBar
with a horizontal orientation - See Also:
JScrollBar
getHorizontalScrollBar
public JScrollBar getHorizontalScrollBar()
- 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)
- 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()
- Returns a
JScrollPane.ScrollBar
by default. Subclasses may override this method to forceScrollPaneUI
implementations to use aJScrollBar
subclass. Used byScrollPaneUI
implementations to create the vertical scrollbar.- Returns:
- a
JScrollBar
with a vertical orientation - See Also:
JScrollBar
getVerticalScrollBar
public JScrollBar getVerticalScrollBar()
- 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)
- 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) insetViewportView
,setRowHeaderView
, andsetColumnHeaderView
. Subclasses may override this method to return a subclass ofJViewport
.- Returns:
- a new
JViewport
getViewport
public JViewport getViewport()
- Returns the current
JViewport
.- Returns:
- the
viewport
property - See Also:
setViewport(javax.swing.JViewport)
setViewport
public void setViewport(JViewport viewport)
- 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 isnull
, the old viewport is still removed and the new viewport is set tonull
- See Also:
createViewport()
,getViewport()
,setViewportView(java.awt.Component)
setViewportView
public void setViewportView(Component view)
- 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()
- Returns the row header.
- Returns:
- the
rowHeader
property - See Also:
setRowHeader(javax.swing.JViewport)
setRowHeader
public void setRowHeader(JViewport rowHeader)
- 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 scroll pane.Most applications will find it more convenient to use
setRowHeaderView
to add a row header component and its viewport to the scroll pane.- Parameters:
rowHeader
- the new row header to be used; ifnull
the old row header is still removed and the new rowHeader is set tonull
- See Also:
getRowHeader()
,setRowHeaderView(java.awt.Component)
setRowHeaderView
public void setRowHeaderView(Component view)
- 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()
- Returns the column header.
- Returns:
- the
columnHeader
property - See Also:
setColumnHeader(javax.swing.JViewport)
setColumnHeader
public void setColumnHeader(JViewport columnHeader)
- Removes the old columnHeader, if it exists; if the new columnHeader
isn't
null
, syncs the x coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scroll pane.Most applications will find it more convenient to use
setColumnHeaderView
to add a column header component and its viewport to the scroll pane.
setColumnHeaderView
public void setColumnHeaderView(Component view)
- 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)
- Returns the component at the specified corner. The
key
value specifying the corner is one of:- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
- ScrollPaneConstants.LOWER_LEADING_CORNER
- ScrollPaneConstants.LOWER_TRAILING_CORNER
- ScrollPaneConstants.UPPER_LEADING_CORNER
- ScrollPaneConstants.UPPER_TRAILING_CORNER
- Parameters:
key
- one of the values as shown above- Returns:
- the corner component (which may be
null
) identified by the given key, ornull
if the key is invalid - See Also:
setCorner(java.lang.String, java.awt.Component)
setCorner
public void setCorner(String key, Component corner)
- 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:
- ScrollPaneConstants.LOWER_LEFT_CORNER
- ScrollPaneConstants.LOWER_RIGHT_CORNER
- ScrollPaneConstants.UPPER_LEFT_CORNER
- ScrollPaneConstants.UPPER_RIGHT_CORNER
- ScrollPaneConstants.LOWER_LEADING_CORNER
- ScrollPaneConstants.LOWER_TRAILING_CORNER
- ScrollPaneConstants.UPPER_LEADING_CORNER
- ScrollPaneConstants.UPPER_TRAILING_CORNER
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 incorner
- one of the following components:- lowerLeft
- lowerRight
- upperLeft
- upperRight
- Throws:
IllegalArgumentException
- if corner key is invalid
setComponentOrientation
public void setComponentOrientation(ComponentOrientation co)
- Sets the orientation for the vertical and horizontal
scrollbars as determined by the
ComponentOrientation
argument.- Overrides:
setComponentOrientation
in classComponent
- 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:
ComponentOrientation
isWheelScrollingEnabled
public boolean isWheelScrollingEnabled()
- 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)
- 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()
,MouseWheelEvent
,MouseWheelListener
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 benull
.- Overrides:
paramString
in classJComponent
- Returns:
- a string representation of this
JScrollPane
.
getAccessibleContext
public AccessibleContext getAccessibleContext()
- 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 interfaceAccessible
- Overrides:
getAccessibleContext
in classJComponent
- Returns:
- an AccessibleJScrollPane that serves as the AccessibleContext of this JScrollPane
|
Java™ Platform Standard Ed. 6 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2011, Oracle and/or its affiliates. All rights reserved.