java.lang.Object | |
↳ | javax.swing.ScrollPaneLayout |
![]() |
The layout manager used by JScrollPane
.
JScrollPaneLayout
is
responsible for nine components: a viewport, two scrollbars,
a row header, a column header, and four "corner" components.
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
.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ScrollPaneLayout.UIResource | The UI resource version of ScrollPaneLayout . |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
colHead | The column header child. | ||||||||||
hsb | The scrollpane's horizontal scrollbar child. | ||||||||||
hsbPolicy | The display policy for the horizontal scrollbar. | ||||||||||
lowerLeft | The component to display in the lower left corner. | ||||||||||
lowerRight | The component to display in the lower right corner. | ||||||||||
rowHead | The row header child. | ||||||||||
upperLeft | The component to display in the upper left corner. | ||||||||||
upperRight | The component to display in the upper right corner. | ||||||||||
viewport | The scrollpane's viewport child. | ||||||||||
vsb | The scrollpane's vertical scrollbar child. | ||||||||||
vsbPolicy | The display policy for the vertical scrollbar. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the specified component to the layout.
| |||||||||||
Returns the
JViewport object that is the column header. | |||||||||||
Returns the
Component at the specified corner. | |||||||||||
Returns the
JScrollBar object that handles horizontal scrolling. | |||||||||||
Returns the horizontal scrollbar-display policy.
| |||||||||||
Returns the
JViewport object that is the row header. | |||||||||||
Returns the
JScrollBar object that handles vertical scrolling. | |||||||||||
Returns the vertical scrollbar-display policy.
| |||||||||||
Returns the
JViewport object that displays the
scrollable contents. | |||||||||||
This method is deprecated.
As of JDK version Swing1.1
replaced by
JScrollPane.getViewportBorderBounds() .
| |||||||||||
Lays out the scrollpane.
| |||||||||||
The minimum size of a
ScrollPane is the size of the insets
plus minimum size of the viewport, plus the scrollpane's
viewportBorder insets, plus the minimum size
of the visible headers, plus the minimum size of the
scrollbars whose displayPolicy isn't NEVER. | |||||||||||
The preferred size of a
ScrollPane is the size of the insets,
plus the preferred size of the viewport, plus the preferred size of
the visible headers, plus the preferred size of the scrollbars
that will appear given the current view and the current
scrollbar displayPolicies. | |||||||||||
Removes the specified component from the layout.
| |||||||||||
Sets the horizontal scrollbar-display policy.
| |||||||||||
Sets the vertical scrollbar-display policy.
| |||||||||||
This method is invoked after the ScrollPaneLayout is set as the
LayoutManager of a
JScrollPane . |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Removes an existing component.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
The scrollpane's horizontal scrollbar child.
Default is a JScrollBar
.
The display policy for the horizontal scrollbar.
The default is ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
.
This field is obsolete, please use the JScrollPane
field instead.
The component to display in the lower left corner.
Default is null
.
The component to display in the lower right corner.
Default is null
.
The component to display in the upper left corner.
Default is null
.
The component to display in the upper right corner.
Default is null
.
The scrollpane's viewport child.
Default is an empty JViewport
.
The scrollpane's vertical scrollbar child.
Default is a JScrollBar
.
The display policy for the vertical scrollbar.
The default is ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
.
This field is obsolete, please use the JScrollPane
field instead.
Adds the specified component to the layout. The layout is identified using one of:
s | the component identifier |
---|---|
c | the the component to be added |
IllegalArgumentException | if s is an invalid key
|
---|
Returns the JViewport
object that is the column header.
JViewport
object that is the column headerReturns the Component
at the specified corner.
key | the String specifying the corner |
---|
Component
at the specified corner, as defined in
ScrollPaneConstants
; if key
is not one of the
four corners, null
is returnedReturns the JScrollBar
object that handles horizontal scrolling.
JScrollBar
object that handles horizontal scrollingReturns the horizontal scrollbar-display policy.
Returns the JViewport
object that is the row header.
JViewport
object that is the row headerReturns the JScrollBar
object that handles vertical scrolling.
JScrollBar
object that handles vertical scrollingReturns the vertical scrollbar-display policy.
Returns the JViewport
object that displays the
scrollable contents.
JViewport
object that displays the scrollable contents
This method is deprecated.
As of JDK version Swing1.1
replaced by JScrollPane.getViewportBorderBounds()
.
Returns the bounds of the border around the specified scroll pane's viewport.
Lays out the scrollpane. The positioning of components depends on the following constraints:
displayPolicy
is ALWAYS, it's treated like the row header with respect to its
dimensions and is made visible.
null
viewportBorder
, then space is allocated for that.
parent | the Container to lay out
|
---|
The minimum size of a ScrollPane
is the size of the insets
plus minimum size of the viewport, plus the scrollpane's
viewportBorder insets, plus the minimum size
of the visible headers, plus the minimum size of the
scrollbars whose displayPolicy isn't NEVER.
parent | the Container that will be laid out |
---|
Dimension
object specifying the minimum size
The preferred size of a ScrollPane
is the size of the insets,
plus the preferred size of the viewport, plus the preferred size of
the visible headers, plus the preferred size of the scrollbars
that will appear given the current view and the current
scrollbar displayPolicies.
Note that the rowHeader is calculated as part of the preferred width and the colHeader is calculated as part of the preferred size.
parent | the Container that will be laid out |
---|
Dimension
object specifying the preferred size of the
viewport and any scrollbarsRemoves the specified component from the layout.
c | the component to remove |
---|
Sets the horizontal scrollbar-display policy. The options are:
JScrollPane
version
of this method. It only exists for backwards compatibility
with the Swing 1.0.2 (and earlier) versions of this class.x | an int giving the display policy |
---|
IllegalArgumentException | if x is not a valid
horizontal scrollbar policy, as listed above
|
---|
Sets the vertical scrollbar-display policy. The options are:
JScrollPane
version
of this method. It only exists for backwards compatibility
with the Swing 1.0.2 (and earlier) versions of this class.x | an integer giving the display policy |
---|
IllegalArgumentException | if x is an invalid
vertical scroll bar policy, as listed above
|
---|
This method is invoked after the ScrollPaneLayout is set as the
LayoutManager of a JScrollPane
.
It initializes all of the internal fields that
are ordinarily set by addLayoutComponent
. For example:
ScrollPaneLayout mySPLayout = new ScrollPanelLayout() { public void layoutContainer(Container p) { super.layoutContainer(p); // do some extra work here ... } }; scrollpane.setLayout(mySPLayout):
Removes an existing component. When a new component, such as the left corner, or vertical scrollbar, is added, the old one, if it exists, must be removed.
This method returns newC
. If oldC
is
not equal to newC
and is non-null
,
it will be removed from its parent.
oldC | the Component to replace |
---|---|
newC | the Component to add |
newC