public class ScrollPaneLayout extends Objectimplements LayoutManager , ScrollPaneConstants , Serializable
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 JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
JScrollPane,
JViewport
| Modifier and Type | Class and Description |
|---|---|
static class |
ScrollPaneLayout
The UI resource version of
ScrollPaneLayout.
|
| Modifier and Type | Field and Description |
|---|---|
protected JViewport |
colHead
The column header child.
|
protected JScrollBar |
hsb
The scrollpane's horizontal scrollbar child.
|
protected int |
hsbPolicy
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 |
rowHead
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 JViewport |
viewport
The scrollpane's viewport child.
|
protected JScrollBar |
vsb
The scrollpane's vertical scrollbar child.
|
protected int |
vsbPolicy
The display policy for the vertical scrollbar.
|
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT| Constructor and Description |
|---|
ScrollPaneLayout()
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLayoutComponent(String
Adds the specified component to the layout.
|
protected Component |
addSingletonComponent(Component
Removes an existing component.
|
JViewport |
getColumnHeader()
Returns the
JViewport object that is the column header.
|
Component |
getCorner(String
Returns the
Component at the specified corner.
|
JScrollBar |
getHorizontalScrollBar()
Returns the
JScrollBar object that handles horizontal scrolling.
|
int |
getHorizontalScrollBarPolicy()
Returns the horizontal scrollbar-display policy.
|
JViewport |
getRowHeader()
Returns the
JViewport object that is the row header.
|
JScrollBar |
getVerticalScrollBar()
Returns the
JScrollBar object that handles vertical scrolling.
|
int |
getVerticalScrollBarPolicy()
Returns the vertical scrollbar-display policy.
|
JViewport |
getViewport()
Returns the
JViewport object that displays the scrollable contents.
|
Rectangle |
getViewportBorderBounds(JScrollPane
Deprecated.
As of JDK version Swing1.1 replaced by
JScrollPane.getViewportBorderBounds().
|
void |
layoutContainer(Container
Lays out the scrollpane.
|
Dimension |
minimumLayoutSize(Container
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.
|
Dimension |
preferredLayoutSize(Container
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.
|
void |
removeLayoutComponent(Component
Removes the specified component from the layout.
|
void |
setHorizontalScrollBarPolicy(int x)
Sets the horizontal scrollbar-display policy.
|
void |
setVerticalScrollBarPolicy(int x)
Sets the vertical scrollbar-display policy.
|
void |
syncWithScrollPane(JScrollPane
This method is invoked after the ScrollPaneLayout is set as the LayoutManager of a
JScrollPane.
|
protected JViewportviewport
JViewport.
protected JScrollBarvsb
JScrollBar.
protected JScrollBarhsb
JScrollBar.
protected JViewportrowHead
null.
protected JViewportcolHead
null.
protected ComponentlowerLeft
null.
protected ComponentlowerRight
null.
protected ComponentupperLeft
null.
protected ComponentupperRight
null.
protected int vsbPolicy
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED.
This field is obsolete, please use the JScrollPane field instead.
protected int hsbPolicy
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED.
This field is obsolete, please use the JScrollPane field instead.
public void syncWithScrollPane(JScrollPanesp)
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):
protected ComponentaddSingletonComponent(Component oldC, Component newC)
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
public void addLayoutComponent(Strings, Component c)
addLayoutComponent in interface
LayoutManager
s - the component identifier
c - the the component to be added
IllegalArgumentException - if
s is an invalid key
public void removeLayoutComponent(Componentc)
removeLayoutComponent in interface
LayoutManager
c - the component to remove
public int getVerticalScrollBarPolicy()
setVerticalScrollBarPolicy(int)
public void setVerticalScrollBarPolicy(int x)
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
public int getHorizontalScrollBarPolicy()
setHorizontalScrollBarPolicy(int)
public void setHorizontalScrollBarPolicy(int x)
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
public JViewportgetViewport()
JViewport object that displays the scrollable contents.
JViewport object that displays the scrollable contents
JScrollPane.getViewport()
public JScrollBargetHorizontalScrollBar()
JScrollBar object that handles horizontal scrolling.
JScrollBar object that handles horizontal scrolling
JScrollPane.getHorizontalScrollBar()
public JScrollBargetVerticalScrollBar()
JScrollBar object that handles vertical scrolling.
JScrollBar object that handles vertical scrolling
JScrollPane.getVerticalScrollBar()
public JViewportgetRowHeader()
JViewport object that is the row header.
JViewport object that is the row header
JScrollPane.getRowHeader()
public JViewportgetColumnHeader()
JViewport object that is the column header.
JViewport object that is the column header
JScrollPane.getColumnHeader()
public ComponentgetCorner(String key)
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 returned
JScrollPane.getCorner(java.lang.String)
public DimensionpreferredLayoutSize(Container parent)
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.
preferredLayoutSize in interface
LayoutManager
parent - the
Container that will be laid out
Dimension object specifying the preferred size of the viewport and any scrollbars
ViewportLayout,
LayoutManager
public DimensionminimumLayoutSize(Container parent)
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.
minimumLayoutSize in interface
LayoutManager
parent - the
Container that will be laid out
Dimension object specifying the minimum size
LayoutManager.preferredLayoutSize(java.awt.Container)
public void layoutContainer(Containerparent)
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. layoutContainer in interface
LayoutManager
parent - the
Container to lay out
@Deprecated public RectanglegetViewportBorderBounds(JScrollPane scrollpane)
JScrollPane.getViewportBorderBounds().