ProgramixGenericLib v5.0.1

com.programix.gui.layout
Class FormLayout

java.lang.Object
  extended by com.programix.gui.layout.AbstractTableLayout
      extended by com.programix.gui.layout.AnchorTableLayout
          extended by com.programix.gui.layout.FormLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable

public class FormLayout
extends AnchorTableLayout

Lays out the components in two (typically) columns, generally with the label in the left column and the input component in the right column. The default number of columns is two, but this can be changed via setColumnCount(int). Each column may be a different width and each row may be a different height. See AnchorTableLayout for further details.

When a component is smaller than the cell space allotted, it will not necessarily be stretched, but anchored within the space (see AnchorPoint). Components in the left column are (by default) anchored as specified by AnchorPoint.EAST. Components in the right column are (by default) anchored as specified by AnchorPoint.WEST. This LayoutManager is very useful for laying out a standard form.

Example: FormLayoutDemo
Could have been created from:

 JPanel formPane = new JPanel(new FormLayout());
 formPane.add(new JLabel("Last Name:"));
 formPane.add(new JTextField(25));
 formPane.add(new JLabel("First Name:"));
 formPane.add(new JTextField(20));
 formPane.add(new JLabel());
 formPane.add(new JCheckBox("Active", true));
 formPane.add(new JLabel("Date of Birth:"));
 formPane.add(new JTextField(8));
 
 JTextArea ta = new JTextArea(5, 10);
 ta.setWrapStyleWord(true);
 ta.setLineWrap(true);
 JScrollPane sp = new JScrollPane(ta);
 formPane.add(new JLabel("Notes:"), AnchorPoint.NORTHEAST);
 formPane.add(sp, AnchorPoint.CENTER_FLEX_BOTH);
 
 formPane.add(new JLabel("Age:"));
 formPane.add(new JTextField(3));
 formPane.add(new JLabel("Start Date:"));
 formPane.add(new JTextField(8));
 

Author:
Paul Hyde
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.programix.gui.layout.AnchorTableLayout
AnchorTableLayout.AnchorTableCellData
 
Nested classes/interfaces inherited from class com.programix.gui.layout.AbstractTableLayout
AbstractTableLayout.CellData
 
Field Summary
 
Fields inherited from class com.programix.gui.layout.AbstractTableLayout
anchorPoint, borderGap, colGap, columnCoordinator, DEFAULT_ANCHOR_POINT, DEFAULT_BORDER_GAP, DEFAULT_COL_GAP, DEFAULT_ROW_GAP, ignoreInvisibleComponents, rowGap
 
Constructor Summary
FormLayout()
          Creates a standard two-column form layout.
FormLayout(AnchorPoint anchorPoint)
          Creates a standard two-column form layout.
FormLayout(int borderGap)
          Creates a standard two-column form layout.
FormLayout(int borderGap, AnchorPoint anchorPoint)
          Creates a standard two-column form layout.
FormLayout(int rowGap, int colGap, AnchorPoint anchorPoint)
          Creates a standard two-column form layout.
FormLayout(int rowGap, int colGap, int borderGap)
          Creates a standard two-column form layout.
FormLayout(int rowGap, int colGap, int borderGap, AnchorPoint anchorPoint)
          Creates a standard two-column form layout.
 
Method Summary
protected  AbstractTableLayout.CellData createCellData(Container pane)
          This implementation returns a an instance of AnchorTableLayout.AnchorTableCellData with a default anchor for all columns of AnchorPoint.CENTER.
 
Methods inherited from class com.programix.gui.layout.AnchorTableLayout
addLayoutComponent, getColumnAnchorPoint, getColumnCount, getColumnHeaderAnchorPoint, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize, removeLayoutComponent, setColumnAnchorPoint, setColumnCount, setColumnHeaderAnchorPoint
 
Methods inherited from class com.programix.gui.layout.AbstractTableLayout
addLayoutComponent, getAnchorPoint, getBorderGap, getColumnCoordinator, getColumnGap, getRowGap, isIgnoreInvisibleComponents, layoutContainer, minimumLayoutSize, preferredLayoutSize, setAnchorPoint, setBorderGap, setColumnCoordinator, setColumnGap, setIgnoreInvisibleComponents, setRowGap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.LayoutManager
addLayoutComponent, layoutContainer, minimumLayoutSize, preferredLayoutSize
 

Constructor Detail

FormLayout

public FormLayout(int rowGap,
                  int colGap,
                  int borderGap,
                  AnchorPoint anchorPoint)
Creates a standard two-column form layout.

Parameters:
rowGap - - space between rows. See setRowGap.
colGap - - space between columns. See setColumnGap.
borderGap - - space around the outside of the form. See setBorderGap.
anchorPoint - - region to anchor to when there is extra space See setAnchorPoint.

FormLayout

public FormLayout(int rowGap,
                  int colGap,
                  int borderGap)
Creates a standard two-column form layout. Uses AbstractTableLayout.DEFAULT_ANCHOR_POINT.

Parameters:
rowGap - - space between rows. See setRowGap.
colGap - - space between columns. See setColumnGap.
borderGap - - space around the outside of the form. See setBorderGap.

FormLayout

public FormLayout(int rowGap,
                  int colGap,
                  AnchorPoint anchorPoint)
Creates a standard two-column form layout. Uses AbstractTableLayout.DEFAULT_BORDER_GAP.

Parameters:
rowGap - - space between rows. See setRowGap.
colGap - - space between columns. See setColumnGap.
anchorPoint - - region to anchor to when there is extra space See setAnchorPoint.

FormLayout

public FormLayout(int borderGap)
Creates a standard two-column form layout. Uses AbstractTableLayout.DEFAULT_ROW_GAP. Uses AbstractTableLayout.DEFAULT_COL_GAP. Uses AbstractTableLayout.DEFAULT_ANCHOR_POINT.

Parameters:
borderGap - - space around the outside of the form. See setBorderGap.

FormLayout

public FormLayout(int borderGap,
                  AnchorPoint anchorPoint)
Creates a standard two-column form layout. Uses AbstractTableLayout.DEFAULT_ROW_GAP. Uses AbstractTableLayout.DEFAULT_COL_GAP.

Parameters:
borderGap - - space around the outside of the form. See setBorderGap.
anchorPoint - - region to anchor to when there is extra space See setAnchorPoint.

FormLayout

public FormLayout(AnchorPoint anchorPoint)
Creates a standard two-column form layout. Uses AbstractTableLayout.DEFAULT_ROW_GAP. Uses AbstractTableLayout.DEFAULT_COL_GAP. Uses AbstractTableLayout.DEFAULT_BORDER_GAP.

Parameters:
anchorPoint - - region to anchor to when there is extra space See setAnchorPoint.

FormLayout

public FormLayout()
Creates a standard two-column form layout. Uses AbstractTableLayout.DEFAULT_ROW_GAP. Uses AbstractTableLayout.DEFAULT_COL_GAP. Uses AbstractTableLayout.DEFAULT_BORDER_GAP. Uses AbstractTableLayout.DEFAULT_ANCHOR_POINT.

Method Detail

createCellData

protected AbstractTableLayout.CellData createCellData(Container pane)
Description copied from class: AnchorTableLayout
This implementation returns a an instance of AnchorTableLayout.AnchorTableCellData with a default anchor for all columns of AnchorPoint.CENTER. If this is appropriate for a subclass, then the subclass does not need to override this method.

Overrides:
createCellData in class AnchorTableLayout

ProgramixGenericLib v5.0.1

Copyright © 2001-2009 Programix Incorporated. All rights reserved. ProgramixGenericLib is free and is OSI Certified Open Source Software under the BSD license.