UC Berkeley Group for User Interface Research
Updated November 17, 2000

edu.berkeley.guir.lib.gesture.util
Class FlowScrollLayout

java.lang.Object
  |
  +--java.awt.FlowLayout
        |
        +--edu.berkeley.guir.lib.gesture.util.FlowScrollLayout
All Implemented Interfaces:
ComponentListener, ContainerListener, EventListener, LayoutManager, Serializable

public class FlowScrollLayout
extends FlowLayout
implements ComponentListener, ContainerListener

This class is a replacement for a FlowLayout inside a JScrollPane. It can be used as a plain FlowLayout, but it is intended to be used on a container inside a JScrollPane. If it is the layout for a Container that is the view of a JViewport inside a JScrollPane, then it will cause the Container's children to be wrapped so that the JScrollPane only scrolls vertically.

It can optionally resize all children on each row to be as tall as the tallest one. IMHO, this often looks better, but is off by default for compatiblity with FlowLayout.

Note:Each FlowScrollLayout should be used for only one Container.

This software is distributed under the Berkeley Software License.

See Also:
Serialized Form

Fields inherited from class java.awt.FlowLayout
CENTER, LEADING, LEFT, RIGHT, TRAILING
 
Constructor Summary
FlowScrollLayout()
           
FlowScrollLayout(Container target)
           
FlowScrollLayout(JScrollPane scrollPane)
           
FlowScrollLayout(JScrollPane scrollPane, Container target)
           
FlowScrollLayout(JScrollPane scrollPane, Container target, boolean uniformHeight)
           
 
Method Summary
 void componentAdded(ContainerEvent e)
           
 void componentHidden(ComponentEvent e)
           
 void componentMoved(ComponentEvent e)
           
 void componentRemoved(ContainerEvent e)
           
 void componentResized(ComponentEvent e)
           
 void componentShown(ComponentEvent e)
           
protected  Dimension computeDesiredSize()
          Follow the layout algorithm that FlowLayout uses to compute how big we would like to be, given the size of the containing JScrollPane.
 boolean isUniformHeight()
           
 void layoutContainer(Container c)
           
static void setHeights(Container container, int height, int startIndex, int endIndex)
          Set the preferred size of all JComponents inside container to have height height, starting at the startIndex'th child and going up to endIndex-1.
static void setPreferredHeight(JComponent comp, int height)
          Set preferredSize of comp to be Dimension(current preferredSize.width, height)
 void setScrollPane(JScrollPane scrollPane)
           
 void setUniformHeight(boolean on)
          If uniformHeight is turned on, all widgets on each row will have their preferred height set to the height of the tallest one (based on preferredSize).
protected  void updateLayout()
          Update the layout of the managed widget and the containing scrollbar (only if the current size doesn't match the desired size)
 
Methods inherited from class java.awt.FlowLayout
addLayoutComponent, getAlignment, getHgap, getVgap, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setAlignment, setHgap, setVgap, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlowScrollLayout

public FlowScrollLayout()

FlowScrollLayout

public FlowScrollLayout(Container target)

FlowScrollLayout

public FlowScrollLayout(JScrollPane scrollPane)

FlowScrollLayout

public FlowScrollLayout(JScrollPane scrollPane,
                        Container target)

FlowScrollLayout

public FlowScrollLayout(JScrollPane scrollPane,
                        Container target,
                        boolean uniformHeight)
Method Detail

setScrollPane

public void setScrollPane(JScrollPane scrollPane)

setUniformHeight

public void setUniformHeight(boolean on)
If uniformHeight is turned on, all widgets on each row will have their preferred height set to the height of the tallest one (based on preferredSize).

isUniformHeight

public boolean isUniformHeight()

computeDesiredSize

protected Dimension computeDesiredSize()
Follow the layout algorithm that FlowLayout uses to compute how big we would like to be, given the size of the containing JScrollPane. Should not be called unless a non-null JScrollPane has been specified in the constructor or with setScrollPane.

setHeights

public static void setHeights(Container container,
                              int height,
                              int startIndex,
                              int endIndex)
Set the preferred size of all JComponents inside container to have height height, starting at the startIndex'th child and going up to endIndex-1.

setPreferredHeight

public static void setPreferredHeight(JComponent comp,
                                      int height)
Set preferredSize of comp to be Dimension(current preferredSize.width, height)

updateLayout

protected void updateLayout()
Update the layout of the managed widget and the containing scrollbar (only if the current size doesn't match the desired size)

layoutContainer

public void layoutContainer(Container c)
Overrides:
layoutContainer in class FlowLayout

componentResized

public void componentResized(ComponentEvent e)
Specified by:
componentResized in interface ComponentListener

componentMoved

public void componentMoved(ComponentEvent e)
Specified by:
componentMoved in interface ComponentListener

componentShown

public void componentShown(ComponentEvent e)
Specified by:
componentShown in interface ComponentListener

componentHidden

public void componentHidden(ComponentEvent e)
Specified by:
componentHidden in interface ComponentListener

componentAdded

public void componentAdded(ContainerEvent e)
Specified by:
componentAdded in interface ContainerListener

componentRemoved

public void componentRemoved(ContainerEvent e)
Specified by:
componentRemoved in interface ContainerListener

Copyright Information