com.darwinsys.swingui.layout
Class ColumnLayout

java.lang.Object
  extended by com.darwinsys.swingui.layout.ColumnLayout
All Implemented Interfaces:
java.awt.LayoutManager

public class ColumnLayout
extends java.lang.Object
implements java.awt.LayoutManager

ColumnLayout, a Single-Column Layout Manager for AWT/Swing. Sort of a cross between BoxLayout and GridLayout(0, x). Displays components in a single row or column based on the alignment given to the constructor, with optional padding.

There is a utility method for adding space between the previous and next components, which (like Menu.addSeparator()) adds a fixed-size non-visible component between two added components.

Note: The current version of ColumnLayout doesn't resize.

Version:
$Id: ColumnLayout.java,v 1.14 2006/10/13 13:06:48 ian Exp $
Author:
Ian Darwin, http://www.darwinsys.com/

Nested Class Summary
protected static class ColumnLayout.Spacer
          Class to represent a spacer, like Menubar.separator.
 
Field Summary
protected  int alignment
          The alignment for this ColumnLayout
protected  int hPadding
          The X padding for this ColumnLayout
protected  int minh
          The minimum height of each component
protected  int minw
          The minimum width of each component
protected  int vPadding
          The Y padding for this ColumnLayout
static int X_AXIS
          Constant for X AXIS (horizontal column) alignment
static int Y_AXIS
          Constant for Y AXIS (vertical column) alignment
 
Constructor Summary
ColumnLayout(int dirn)
          Construct a ColumnLayout given only an alignment.
ColumnLayout(int dirn, int pad)
          Construct a ColumnLayout given an alignment and a padding amount.
ColumnLayout(int dirn, int hpad, int vpad)
          Construct a ColumnLayout given an alignment and h,v padding amounts.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component c)
          Called by AWT when the user uses the form add(name, Component).
 void addSpacer(java.awt.Container target)
          Utility method to add a "spacer"
protected  java.awt.Dimension doLayout(java.awt.Container target)
          Used internally: compute the layout and the maximal preferred width & height
TODO XXX NEED TO SCALE BY TARGSIZE?
 void layoutContainer(java.awt.Container target)
          Called by AWT to lay out the components in the target Container at its current size.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Called from AWT to calculate the minimum size dimensions for the target panel given the components in it.
 java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Called by AWT to compute the preferred size for the target panel given our list of the components that it contains.
 void removeLayoutComponent(java.awt.Component c)
          Called by AWT to remove a given component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_AXIS

public static final int X_AXIS
Constant for X AXIS (horizontal column) alignment

See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
Constant for Y AXIS (vertical column) alignment

See Also:
Constant Field Values

alignment

protected final int alignment
The alignment for this ColumnLayout


hPadding

protected final int hPadding
The X padding for this ColumnLayout


vPadding

protected final int vPadding
The Y padding for this ColumnLayout


minw

protected int minw
The minimum width of each component


minh

protected int minh
The minimum height of each component

Constructor Detail

ColumnLayout

public ColumnLayout(int dirn)
Construct a ColumnLayout given only an alignment.


ColumnLayout

public ColumnLayout(int dirn,
                    int pad)
Construct a ColumnLayout given an alignment and a padding amount.


ColumnLayout

public ColumnLayout(int dirn,
                    int hpad,
                    int vpad)
Construct a ColumnLayout given an alignment and h,v padding amounts.

Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component c)
Called by AWT when the user uses the form add(name, Component). Adds the specified component with the specified name to the layout. Not necessary to use this form.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - String with location for component c
c - Component to be added.

layoutContainer

public void layoutContainer(java.awt.Container target)
Called by AWT to lay out the components in the target Container at its current size.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
target - Container whose components are to be laid out.

doLayout

protected java.awt.Dimension doLayout(java.awt.Container target)
Used internally: compute the layout and the maximal preferred width & height
TODO XXX NEED TO SCALE BY TARGSIZE?


minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Called from AWT to calculate the minimum size dimensions for the target panel given the components in it. But we use our own list of named insertions, not the list of Components that the container keeps.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
target - Container to calculate for

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Called by AWT to compute the preferred size for the target panel given our list of the components that it contains.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
target - Container to calculate for

addSpacer

public void addSpacer(java.awt.Container target)
Utility method to add a "spacer"


removeLayoutComponent

public void removeLayoutComponent(java.awt.Component c)
Called by AWT to remove a given component from the layout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
c - Component to be removed


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.