com.darwinsys.swingui.layout
Class EntryLayout

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

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

A simple layout manager, for "Entry" areas ith e.g., a list of labels and their corresponding JTextFields. These typically look like:

    Login: _______________
 Password: _______________
 
Basically two (or more) columns of different, but constant, widths. Note: all columns must be the same height!.

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. Note: As with GridLayout, the number of items added must be an even multiple of the number of columns. If not, exceptions may be thrown!

Version:
$Id: EntryLayout.java,v 1.13 2006/12/05 21:46:54 ian Exp $
Author:
Ian F. Darwin, http://www.darwinsys.com/

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[] relWidths)
          Construct an EntryLayout with widths and with default padding amounts.
EntryLayout(double[] relWidths, int h, int v)
          Construct an EntryLayout with widths and padding specified.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component with the specified constraint to the layout; required by LayoutManager but not used.
protected  java.awt.Dimension computeLayoutSize(java.awt.Container parent, int hp, int vp)
          Compute the size of the whole mess.
 void layoutContainer(java.awt.Container parent)
          Lays out the container in the specified panel.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Find the minimum Dimension for the specified container given the components therein.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout; required by LayoutManager, but does nothing.
 
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

See Also:
Constant Field Values

VPAD

protected static final int VPAD
The default padding

See Also:
Constant Field Values

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[] relWidths,
                   int h,
                   int v)
Construct an EntryLayout with widths and padding specified.

Parameters:
relWidths - Array of doubles specifying relative column widths.
h - Horizontal padding between items
v - Vertical padding between items

EntryLayout

public EntryLayout(double[] relWidths)
Construct an EntryLayout with widths and with default padding amounts.

Parameters:
relWidths - Array of doubles specifying column widths.
Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component with the specified constraint to the layout; required by LayoutManager but not used.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout; required by LayoutManager, but does nothing.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Find the minimum Dimension for the specified container given the components therein.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

computeLayoutSize

protected java.awt.Dimension computeLayoutSize(java.awt.Container parent,
                                               int hp,
                                               int vp)
Compute the size of the whole mess. Serves as the guts of preferredLayoutSize() and minimumLayoutSize().

Parameters:
parent - The container in which to do the layout.
hp - The horizontal padding (may be zero)
vp - The Vertical Padding (may be zero).

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container in the specified panel. This is a row-column type layout; find x, y, width and height of each Component.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - The Container whose children we are laying out.


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