Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javax.swing
Class ScrollPaneLayout

    java.lang.Object
      |
      +--javax.swing.ScrollPaneLayout

Direct Known Subclasses:
  ScrollPaneLayout.UIResource

public class ScrollPaneLayout
extends java.lang.Object
implements java.awt.LayoutManager, ScrollPaneConstants, java.io.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. A future release of Swing will provide support for long term persistence.

See Also:
  `JScrollPane`, `JViewport`, Serialized Form

Inner Class Summary
`static class` | `ScrollPaneLayout.UIResource` The UI resource version of ScrollPaneLayout.

Field Summary
`protected JViewport` | `colHead` The column header child.
`protected JScrollBar` | `hsb` The scrollpanes horizontal scrollbar child.
`protected int` | `hsbPolicy` The display policy for the horizontal scrollbar.
`protected java.awt.Component` | `lowerLeft` The component to display in the lower left corner.
`protected java.awt.Component` | `lowerRight` The component to display in the lower right corner.
`protected JViewport` | `rowHead` The row header child.
`protected java.awt.Component` | `upperLeft` The component to display in the upper left corner.
`protected java.awt.Component` | `upperRight` The component to display in the upper right corner.
`protected JViewport` | `viewport` The scrollpanes viewport child.
`protected JScrollBar` | `vsb` The scrollpanes vertical scrollbar child.
`protected int` | `vsbPolicy` The display policy for the vertical scrollbar.

Constructor Summary
`ScrollPaneLayout()`

Method Summary
`void` | `addLayoutComponent(java.lang.String s, java.awt.Component c)` Adds the specified component to the layout.
`protected java.awt.Component` | `addSingletonComponent(java.awt.Component oldC, java.awt.Component newC)` The method used to replace an existing component (if any) with a new one.
`JViewport` | `getColumnHeader()` Returns the JViewport object that is the column header.
`java.awt.Component` | `getCorner(java.lang.String key)` 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.
`java.awt.Rectangle` | `getViewportBorderBounds(JScrollPane scrollpane)` Deprecated. As of JDK version Swing1.1 replaced by `JScrollPane.getViewportBorderBounds()`.
`void` | `layoutContainer(java.awt.Container parent)` Lay out the scrollpane.
`java.awt.Dimension` | `minimumLayoutSize(java.awt.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.
`java.awt.Dimension` | `preferredLayoutSize(java.awt.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.
`void` | `removeLayoutComponent(java.awt.Component c)` 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 sp)` This method must be called after setting a JScrollPanes layout manager.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### viewport

    protected JViewport viewport

  The scrollpanes viewport child. Default is an empty JViewport.
  See Also:
    `JScrollPane.setViewport(javax.swing.JViewport)`

### vsb

    protected JScrollBar vsb

  The scrollpanes vertical scrollbar child. Default is a JScrollBar.
  See Also:
    `JScrollPane#setVerticalScrollbar`

### hsb

    protected JScrollBar hsb

  The scrollpanes horizontal scrollbar child. Default is a JScrollBar.
  See Also:
    `JScrollPane#setHorizontalScrollbar`

### rowHead

    protected JViewport rowHead

  The row header child. Default is null.
  See Also:
    `JScrollPane.setRowHeader(javax.swing.JViewport)`

### colHead

    protected JViewport colHead

  The column header child. Default is null.
  See Also:
    `JScrollPane.setColumnHeader(javax.swing.JViewport)`

### lowerLeft

    protected java.awt.Component lowerLeft

  The component to display in the lower left corner. Default is null.
  See Also:
    `JScrollPane.setCorner(java.lang.String, java.awt.Component)`

### lowerRight

    protected java.awt.Component lowerRight

  The component to display in the lower right corner. Default is null.
  See Also:
    `JScrollPane.setCorner(java.lang.String, java.awt.Component)`

### upperLeft

    protected java.awt.Component upperLeft

  The component to display in the upper left corner. Default is null.
  See Also:
    `JScrollPane.setCorner(java.lang.String, java.awt.Component)`

### upperRight

    protected java.awt.Component upperRight

  The component to display in the upper right corner. Default is null.
  See Also:
    `JScrollPane.setCorner(java.lang.String, java.awt.Component)`

### vsbPolicy

    protected int vsbPolicy

  The display policy for the vertical scrollbar. The default is JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED.

  This field is obsolete, please use the JScrollPane field instead.

  See Also:
    `JScrollPane.setVerticalScrollBarPolicy(int)`

### hsbPolicy

    protected int hsbPolicy

  The display policy for the horizontal scrollbar. The default is JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED.

  This field is obsolete, please use the JScrollPane field instead.

  See Also:
    `JScrollPane.setHorizontalScrollBarPolicy(int)`

Constructor Detail

### ScrollPaneLayout

    public ScrollPaneLayout()

Method Detail

### syncWithScrollPane

    public void syncWithScrollPane(JScrollPane sp)

  This method must be called after setting a JScrollPanes layout manager. 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):
       mySPLayout.syncWithScrollPane(scrollpane);

### addSingletonComponent

    protected java.awt.Component addSingletonComponent(java.awt.Component oldC,
                                                       java.awt.Component newC)

  The method used to replace an existing component (if any) with a new one. Used to add each different kind of component to a JScrollPane, since there can be one and only one left corner, vertical scrollbar, and so on. So only one of each subcomponent is allowed, the old one is removed (if it exists) when a new one is added.
  Parameters:
    `oldC` - the Component to replace
    `newC` - the Component to add

### addLayoutComponent

    public void addLayoutComponent(java.lang.String s,
                                   java.awt.Component c)

  Adds the specified component to the layout. The layout is identified using one of:
  - JScrollPane.VIEWPORT
  - JScrollPane.VERTICAL_SCROLLBAR
  - JScrollPane.HORIZONTAL_SCROLLBAR
  - JScrollPane.ROW_HEADER
  - JScrollPane.COLUMN_HEADER
  - JScrollPane.LOWER_LEFT_CORNER
  - JScrollPane.LOWER_RIGHT_CORNER
  - JScrollPane.UPPER_LEFT_CORNER
  - JScrollPane.UPPER_RIGHT_CORNER
  Specified by:
    addLayoutComponent in interface java.awt.LayoutManager
  Parameters:
    `s` - the component identifier
    `comp` - the the component to be added

### removeLayoutComponent

    public void removeLayoutComponent(java.awt.Component c)

  Removes the specified component from the layout.
  Specified by:
    removeLayoutComponent in interface java.awt.LayoutManager
  Parameters:
    `c` - the component to remove

### getVerticalScrollBarPolicy

    public int getVerticalScrollBarPolicy()

  Returns the vertical scrollbar-display policy.
  Returns:
    an int giving the display policy
  See Also:
    `setVerticalScrollBarPolicy(int)`

### setVerticalScrollBarPolicy

    public void setVerticalScrollBarPolicy(int x)

  Sets the vertical scrollbar-display policy. The options are:
  - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED
  - JScrollPane.VERTICAL_SCROLLBAR_NEVER
  - JScrollPane.VERTICAL_SCROLLBAR_ALWAYS
  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

### getHorizontalScrollBarPolicy

    public int getHorizontalScrollBarPolicy()

  Returns the horizontal scrollbar-display policy.
  Returns:
    an int giving the display policy
  See Also:
    `setHorizontalScrollBarPolicy(int)`

### setHorizontalScrollBarPolicy

    public void setHorizontalScrollBarPolicy(int x)

  Sets the horizontal scrollbar-display policy. The options are:
  - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED
  - JScrollPane.HOTRIZONTAL_SCROLLBAR_NEVER
  - JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS
  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

### getViewport

    public JViewport getViewport()

  Returns the JViewport object that displays the scrollable contents.
  Returns:
    the JViewport object that displays the scrollable contents
  See Also:
    `JScrollPane.getViewport()`

### getHorizontalScrollBar

    public JScrollBar getHorizontalScrollBar()

  Returns the JScrollbar object that handles horizontal scrolling.
  Returns:
    the JScrollbar object that handles horizontal scrolling
  See Also:
    `JScrollPane.getHorizontalScrollBar()`

### getVerticalScrollBar

    public JScrollBar getVerticalScrollBar()

  Returns the JScrollbar object that handles vertical scrolling.
  Returns:
    the JScrollbar object that handles vertical scrolling
  See Also:
    `JScrollPane.getVerticalScrollBar()`

### getRowHeader

    public JViewport getRowHeader()

  Returns the JViewport object that is the row header.
  Returns:
    the JViewport object that is the row header
  See Also:
    `JScrollPane.getRowHeader()`

### getColumnHeader

    public JViewport getColumnHeader()

  Returns the JViewport object that is the column header.
  Returns:
    the JViewport object that is the column header
  See Also:
    `JScrollPane.getColumnHeader()`

### getCorner

    public java.awt.Component getCorner(java.lang.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 `ScrollPaneConstants`
  See Also:
    `JScrollPane.getCorner(java.lang.String)`

### preferredLayoutSize

    public java.awt.Dimension preferredLayoutSize(java.awt.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.
  Specified by:
    preferredLayoutSize in interface java.awt.LayoutManager
  Parameters:
    `parent` - the Container that will be laid out
  Returns:
    a Dimension object specifying the preferred size of the viewport and any scrollbars.
  See Also:
    `ViewportLayout`, `LayoutManager`

### minimumLayoutSize

    public java.awt.Dimension minimumLayoutSize(java.awt.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.
  Specified by:
    minimumLayoutSize in interface java.awt.LayoutManager
  Parameters:
    `parent` - the Container that will be laid out
  Returns:
    a Dimension object specifying the minimum size

### layoutContainer

    public void layoutContainer(java.awt.Container parent)

  Lay out the scrollpane. The positioning of components depends on the following constraints:
  - The row header, if present and visible, gets its preferred height and the viewports width.
  - The column header, if present and visible, gets its preferred width and the viewports height.
  - If a vertical scrollbar is needed, i.e. if the viewports extent height is smaller than its view height or if the displayPolicy is ALWAYS, it's treated like the row header wrt it's dimensions and it's made visible.
  - If a horizontal scrollbar is needed it's treated like the column header (and see the vertical scrollbar item).
  - If the scrollpane has a non-null viewportBorder, then space is allocated for that.
  - The viewport gets the space available after accounting for the previous constraints.
  - The corner components, if provided, are aligned with the ends of the scrollbars and headers. If there's a vertical scrollbar the right corners appear, if there's a horizontal scrollbar the lower corners appear, a row header gets left corners and a column header gets upper corners.
  Specified by:
    layoutContainer in interface java.awt.LayoutManager
  Parameters:
    `parent` - the Container to lay out

### getViewportBorderBounds

    public java.awt.Rectangle getViewportBorderBounds(JScrollPane scrollpane)

  Deprecated. As of JDK version Swing1.1 replaced by `JScrollPane.getViewportBorderBounds()`.
  Returns the bounds of the border around the specified scroll pane's viewport.
  Returns:
    the size and position of the viewport border

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Swing 1.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug or feature
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.