Class EntryLayout

java.lang.Object
  |
  +--EntryLayout

public class EntryLayout
extends Object
implements LayoutManager

A simple layout manager, for Entry areas like:

    Login: _______________
 Password: _______________
 
Basically two (or more) columns of different, but constant, widths.

Construct instances by passing an array of the column width percentages (as doubles, fractions from 0.1 to 0.9, so 40%,60% would be {0.4, 0.6}). The length of this array uniquely determines the number of columns. Columns are forced to be the relevant widths. As with GridLayout, the number of items added must be an even multiple of the number of columns. If not, exceptions may be thrown!


Field Summary
protected  int COLUMNS
          The number of columns.
protected  int hpad
          The actual padding
protected static int HPAD
          The default padding
protected  boolean validWidths
          True if the list of widths was valid.
protected  int vpad
          The actual padding
protected static int VPAD
          The default padding
protected  double[] widthPercentages
          The array of widths, as decimal fractions (0.4 == 40%, etc.).
 
Constructor Summary
EntryLayout(double[] widths)
          Construct an EntryLayout with widths and with default padding amounts.
EntryLayout(double[] widths, int h, int v)
          Construct an EntryLayout with widths and padding specified.
 
Method Summary
 void addLayoutComponent(String name, Component comp)
          Adds the specified component with the specified constraint to the layout.
protected  Dimension computelayoutSize(Container parent, int hpad, int vpad)
          Compute the size of the whole mess.
 void layoutContainer(Container parent)
          Lays out the container in the specified panel.
 Dimension minimumLayoutSize(Container parent)
          Find the minimum Dimension for the specified container given the components therein.
 Dimension preferredLayoutSize(Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

widthPercentages

protected final double[] widthPercentages
The array of widths, as decimal fractions (0.4 == 40%, etc.).

COLUMNS

protected final int COLUMNS
The number of columns.

HPAD

protected static final int HPAD
The default padding

VPAD

protected static final int VPAD
The default padding

hpad

protected final int hpad
The actual padding

vpad

protected final int vpad
The actual padding

validWidths

protected boolean validWidths
True if the list of widths was valid.
Constructor Detail

EntryLayout

public EntryLayout(double[] widths,
                   int h,
                   int v)
Construct an EntryLayout with widths and padding specified.
Parameters:
widths - Array of doubles specifying column widths.
h - Horizontal padding between items
v - Vertical padding between items

EntryLayout

public EntryLayout(double[] widths)
Construct an EntryLayout with widths and with default padding amounts.
Parameters:
widths - Array of doubles specifying column widths.
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Adds the specified component with the specified constraint to the layout. Required by LayoutManager but not used.
Specified by:
addLayoutComponent in interface LayoutManager
Throws:
IllegalArgumentException - - if called at all.

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the specified component from the layout. Required by LayoutManager, but does nothing.
Specified by:
removeLayoutComponent in interface LayoutManager

layoutContainer

public void layoutContainer(Container parent)
Lays out the container in the specified panel.
Specified by:
layoutContainer in interface LayoutManager

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
Specified by:
preferredLayoutSize in interface LayoutManager

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Find the minimum Dimension for the specified container given the components therein.
Specified by:
minimumLayoutSize in interface LayoutManager

computelayoutSize

protected Dimension computelayoutSize(Container parent,
                                      int hpad,
                                      int vpad)
Compute the size of the whole mess. Serves as the guts of preferredLayoutSize() and minimumLayoutSize().