Home » openjdk-7 » javax » swing » [javadoc | source]
javax.swing
public class: ScrollPaneLayout [javadoc | source]
java.lang.Object
   javax.swing.ScrollPaneLayout

All Implemented Interfaces:
    LayoutManager, ScrollPaneConstants, java$io$Serializable

Direct Known Subclasses:
    UIResource

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 java.beans.XMLEncoder .

Nested Class Summary:
public static class  ScrollPaneLayout.UIResource  The UI resource version of ScrollPaneLayout
Field Summary
protected  JViewport viewport    The scrollpane's viewport child. Default is an empty JViewport.
    Also see:
    JScrollPane#setViewport
 
protected  JScrollBar vsb    The scrollpane's vertical scrollbar child. Default is a JScrollBar.
    Also see:
    JScrollPane#setVerticalScrollBar
 
protected  JScrollBar hsb    The scrollpane's horizontal scrollbar child. Default is a JScrollBar.
    Also see:
    JScrollPane#setHorizontalScrollBar
 
protected  JViewport rowHead    The row header child. Default is null.
    Also see:
    JScrollPane#setRowHeader
 
protected  JViewport colHead    The column header child. Default is null.
    Also see:
    JScrollPane#setColumnHeader
 
protected  Component lowerLeft    The component to display in the lower left corner. Default is null.
    Also see:
    JScrollPane#setCorner
 
protected  Component lowerRight    The component to display in the lower right corner. Default is null.
    Also see:
    JScrollPane#setCorner
 
protected  Component upperLeft    The component to display in the upper left corner. Default is null.
    Also see:
    JScrollPane#setCorner
 
protected  Component upperRight    The component to display in the upper right corner. Default is null.
    Also see:
    JScrollPane#setCorner
 
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.

    Also see:
    JScrollPane#setVerticalScrollBarPolicy
 
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.

    Also see:
    JScrollPane#setHorizontalScrollBarPolicy
 
Method from javax.swing.ScrollPaneLayout Summary:
addLayoutComponent,   addSingletonComponent,   getColumnHeader,   getCorner,   getHorizontalScrollBar,   getHorizontalScrollBarPolicy,   getRowHeader,   getVerticalScrollBar,   getVerticalScrollBarPolicy,   getViewport,   getViewportBorderBounds,   layoutContainer,   minimumLayoutSize,   preferredLayoutSize,   removeLayoutComponent,   setHorizontalScrollBarPolicy,   setVerticalScrollBarPolicy,   syncWithScrollPane
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from javax.swing.ScrollPaneLayout Detail:
 public  void addLayoutComponent(String s,
    Component c) 
    Adds the specified component to the layout. The layout is identified using one of:
    • ScrollPaneConstants.VIEWPORT
    • ScrollPaneConstants.VERTICAL_SCROLLBAR
    • ScrollPaneConstants.HORIZONTAL_SCROLLBAR
    • ScrollPaneConstants.ROW_HEADER
    • ScrollPaneConstants.COLUMN_HEADER
    • ScrollPaneConstants.LOWER_LEFT_CORNER
    • ScrollPaneConstants.LOWER_RIGHT_CORNER
    • ScrollPaneConstants.UPPER_LEFT_CORNER
    • ScrollPaneConstants.UPPER_RIGHT_CORNER
 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.

 public JViewport getColumnHeader() 
    Returns the JViewport object that is the column header.
 public Component getCorner(String key) 
    Returns the Component at the specified corner.
 public JScrollBar getHorizontalScrollBar() 
    Returns the JScrollBar object that handles horizontal scrolling.
 public int getHorizontalScrollBarPolicy() 
    Returns the horizontal scrollbar-display policy.
 public JViewport getRowHeader() 
    Returns the JViewport object that is the row header.
 public JScrollBar getVerticalScrollBar() 
    Returns the JScrollBar object that handles vertical scrolling.
 public int getVerticalScrollBarPolicy() 
    Returns the vertical scrollbar-display policy.
 public JViewport getViewport() 
    Returns the JViewport object that displays the scrollable contents.
 public 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.
 public  void layoutContainer(Container parent) 
    Lays out the scrollpane. The positioning of components depends on the following constraints:
    • The row header, if present and visible, gets its preferred width and the viewport's height.
    • The column header, if present and visible, gets its preferred height and the viewport's width.
    • If a vertical scrollbar is needed, i.e. if the viewport's extent height is smaller than its view height or if the displayPolicy is ALWAYS, it's treated like the row header with respect to its dimensions and is made visible.
    • If a horizontal scrollbar is needed, it is treated like the column header (see the paragraph above regarding the vertical scrollbar).
    • 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 is a vertical scrollbar, the right corners appear; if there is a horizontal scrollbar, the lower corners appear; a row header gets left corners, and a column header gets upper corners.
 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.
 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.

 public  void removeLayoutComponent(Component c) 
    Removes the specified component from the layout.
 public  void setHorizontalScrollBarPolicy(int x) 
    Sets the horizontal scrollbar-display policy. The options are:
    • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED
    • ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER
    • ScrollPaneConstants.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.
 public  void setVerticalScrollBarPolicy(int x) 
    Sets the vertical scrollbar-display policy. The options are:
    • ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
    • ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER
    • ScrollPaneConstants.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.
 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):