FileDocCategorySizeDatePackage
VFlowLayout.javaAPI DocJMF 2.1.1e5442Mon May 12 12:20:56 BST 2003com.sun.media.controls

VFlowLayout

public class VFlowLayout extends Object implements LayoutManager

Fields Summary
public static final String
a_copyright_notice
Licensed Materials - Property of IBM

"Restricted Materials of IBM"

5648-B81

(c) Copyright IBM Corporation 1997,1999 All Rights Reserved

US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corporation.
private int
gap
private int
minWidth
private int
minHeight
private int
preferredWidth
private int
preferredHeight
private boolean
sizeUnknown
Constructors Summary
public VFlowLayout()
flow layout without gap


         
      
        this(0);
    
public VFlowLayout(int v)
flow layout with the specified gap

        gap = v;
    
Methods Summary
public voidaddLayoutComponent(java.lang.String name, java.awt.Component comp)

    
public voidlayoutContainer(java.awt.Container parent)

        Insets insets = parent.insets();
        int maxWidth = parent.size().width
                       - (insets.left + insets.right);
        int maxHeight = parent.size().height
                        - (insets.top + insets.bottom);
        int nComps = parent.countComponents();

        // Go through the components' sizes, if neither preferredLayoutSize()
        // nor minimumLayoutSize() has been called.
        if (sizeUnknown) {
            setSizes(parent);
        }

        int previousWidth = 0, previousHeight = 0;
        int x = 0, y = insets.top + gap/2;
        int rowh = 0, start = 0;
        int yFudge = 0;
        boolean oneColumn = false;

        // Go through the components' sizes, if neither preferredLayoutSize()
        // nor minimumLayoutSize() has been called.
        if (sizeUnknown) {
            setSizes(parent);
        }

        if (maxHeight > preferredHeight) {
            yFudge = (maxHeight - preferredHeight)/(nComps);
        }

        for (int i = 0 ; i < nComps ; i++) {
            Component c = parent.getComponent(i);
            if (c.isVisible()) {
                Dimension d = c.preferredSize();

                if (i!=0)
                  y+=(previousHeight + yFudge + gap);
                else
                  y+=(previousHeight + (yFudge + gap)/2 );

                // Set the component's size and position.
                c.reshape(0, y, maxWidth, d.height);

                previousWidth = d.width;
                previousHeight = d.height;
            }
        }
    
public java.awt.DimensionminimumLayoutSize(java.awt.Container parent)

        Dimension dim = new Dimension(0, 0);
        int nComps = parent.countComponents();

        setSizes(parent);

        //Always add the container's insets!
        Insets insets = parent.insets();
        dim.width = minWidth + insets.left + insets.right;
        dim.height = minHeight + insets.top + insets.bottom;

        sizeUnknown = false;

        return dim;
    
public java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)

        Dimension dim = new Dimension(0, 0);
        int nComps = parent.countComponents();

        setSizes(parent);

        //Always add the container's insets!
        Insets insets = parent.insets();
        dim.width = preferredWidth + insets.left + insets.right;
        dim.height = preferredHeight + insets.top + insets.bottom;

        sizeUnknown = false;

        return dim;
    
public voidremoveLayoutComponent(java.awt.Component comp)

    
private voidsetSizes(java.awt.Container parent)
calculates minimum size and preffered size

        int nComps = parent.countComponents();
        Dimension d = null;

        //Reset preferred/minimum width and height.
        preferredWidth = 0;
        preferredHeight = 0;
        minWidth = 0;
        minHeight = 0;

        for (int i = 0; i < nComps; i++) {
            Component c = parent.getComponent(i);
            if (c.isVisible()) {
                d = c.preferredSize();

                minWidth       = Math.max(c.minimumSize().width, minWidth);
                preferredWidth = Math.max(c.preferredSize().width, preferredWidth);

                minHeight       += (c.minimumSize().height + gap);
                preferredHeight += (c.preferredSize().height + gap);

            }
        }
    
public java.lang.StringtoString()

        return getClass().getName() + "[gap=" + gap +"]";