This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing
class ScrollPaneLayout

java.lang.Object extended by javax.swing.ScrollPaneLayout
All Implemented Interfaces:
LayoutManager, Serializable, ScrollPaneConstants
Direct Known Subclasses:
ScrollPaneLayout.UIResource

public class ScrollPaneLayout
extends Object
implements LayoutManager, ScrollPaneConstants, Serializable

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 {@link java.beans.XMLEncoder}.


Nested Class Summary
static class

           The UI resource version of ScrollPaneLayout.
 
Field Summary
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.
 
Constructor Summary

          
 
Method Summary
 void

          Adds the specified component to the layout.
protected Component

          Removes an existing component.
 JViewport

          Returns the JViewport object that is the column header.
 Component

          Returns the Component at the specified corner.
 JScrollBar

          Returns the JScrollBar object that handles horizontal scrolling.
 int

          Returns the horizontal scrollbar-display policy.
 JViewport

          Returns the JViewport object that is the row header.
 JScrollBar

          Returns the JScrollBar object that handles vertical scrolling.
 int

          Returns the vertical scrollbar-display policy.
 JViewport

          Returns the JViewport object that displays the scrollable contents.
 Rectangle

          Returns the bounds of the border around the specified scroll pane's viewport.
 void

          Lays out the scrollpane.
 Dimension

          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

          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

          Removes the specified component from the layout.
 void

          Sets the horizontal scrollbar-display policy.
 void

          Sets the vertical scrollbar-display policy.
 void

          This method is invoked after the ScrollPaneLayout is set as the LayoutManager of a JScrollPane.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

colHead

protected JViewport colHead
The column header child. Default is null.

hsb

protected JScrollBar hsb
The scrollpane's horizontal scrollbar child. Default is a JScrollBar.

hsbPolicy

protected int hsbPolicy
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.


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.

rowHead

protected JViewport rowHead
The row header child. 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.

viewport

protected JViewport viewport
The scrollpane's viewport child. Default is an empty JViewport.

vsb

protected JScrollBar vsb
The scrollpane's vertical scrollbar child. Default is a JScrollBar.

vsbPolicy

protected int vsbPolicy
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.

Constructor Detail

ScrollPaneLayout

public ScrollPaneLayout()
Method Detail

addLayoutComponent

public void addLayoutComponent(String s,
                               Component c)
Adds the specified component to the layout. The layout is identified using one of:

Parameters:
s - the component identifier
c - the the component to be added

addSingletonComponent

protected Component addSingletonComponent(Component oldC,
                                          Component newC)
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.

Parameters:
oldC - the Component to replace
newC - the Component to add
Returns:
the newC

getColumnHeader

public JViewport getColumnHeader()
Returns the JViewport object that is the column header.

Returns:
the JViewport object that is the column header

getCorner

public Component getCorner(String key)
Returns the Component at the specified corner.

Parameters:
key - the String specifying the corner
Returns:
the Component at the specified corner, as defined in {@link ScrollPaneConstants}; if key is not one of the four corners, null is returned

getHorizontalScrollBar

public JScrollBar getHorizontalScrollBar()
Returns the JScrollBar object that handles horizontal scrolling.

Returns:
the JScrollBar object that handles horizontal scrolling

getHorizontalScrollBarPolicy

public int getHorizontalScrollBarPolicy()
Returns the horizontal scrollbar-display policy.

Returns:
an integer giving the display policy

getRowHeader

public JViewport getRowHeader()
Returns the JViewport object that is the row header.

Returns:
the JViewport object that is the row header

getVerticalScrollBar

public JScrollBar getVerticalScrollBar()
Returns the JScrollBar object that handles vertical scrolling.

Returns:
the JScrollBar object that handles vertical scrolling

getVerticalScrollBarPolicy

public int getVerticalScrollBarPolicy()
Returns the vertical scrollbar-display policy.

Returns:
an integer giving the display policy

getViewport

public JViewport getViewport()
Returns the JViewport object that displays the scrollable contents.

Returns:
the JViewport object that displays the scrollable contents

getViewportBorderBounds

public Rectangle getViewportBorderBounds(JScrollPane scrollpane)
Returns the bounds of the border around the specified scroll pane's viewport.

Parameters:
scrollpane
Returns:
the size and position of the viewport border

layoutContainer

public void layoutContainer(Container parent)
Lays out the scrollpane. The positioning of components depends on the following constraints:

Parameters:
parent - the Container to lay out

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
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.

Parameters:
parent - the Container that will be laid out
Returns:
a Dimension object specifying the minimum size

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
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.

Parameters:
parent - the Container that will be laid out
Returns:
a Dimension object specifying the preferred size of the viewport and any scrollbars

removeLayoutComponent

public void removeLayoutComponent(Component c)
Removes the specified component from the layout.

Parameters:
c - the component to remove

setHorizontalScrollBarPolicy

public void setHorizontalScrollBarPolicy(int x)
Sets the horizontal scrollbar-display policy. The options are: Note: Applications should use the JScrollPane version of this method. It only exists for backwards compatibility with the Swing 1.0.2 (and earlier) versions of this class.

Parameters:
x - an int giving the display policy

setVerticalScrollBarPolicy

public void setVerticalScrollBarPolicy(int x)
Sets the vertical scrollbar-display policy. The options are: Note: Applications should use the JScrollPane version of this method. It only exists for backwards compatibility with the Swing 1.0.2 (and earlier) versions of this class.

Parameters:
x - an integer giving the display policy

syncWithScrollPane

public void syncWithScrollPane(JScrollPane sp)
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):
 

Parameters:
sp


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.