Class FormFactory
- java.lang.Object
-
- com.jgoodies.forms.factories.FormFactory
-
public final class FormFactory extends java.lang.ObjectA factory that creates instances of FormLayout for frequently used form layouts. It makes form creation easier and more consistent.I consider removing the
FormLayoutfactory methods. These seem to be less useful and may lead to poor layout readability. If you want to use these methods, you may consider copying them to your codebase.The forms are described by major and minor columns. Major columns consist of a leading label and a set of related components, for example: a label plus textfield, or label plus textfield plus button. The component part of a major column is divided into minor columns as shown in this layout:
<- major column 1 -> <- major column 2 -> label1 textfield1a textfield1b label2 textfield2a textfield2b label3 textfield3a textfield3b label4 textfield4 label5 textfield5 label6 textfield6
Many forms use 1, 2, 3 or 4 major columns, which in turn are often split into 1, 2, 3 or 4 minor columns.
- Version:
- $Revision$
- Author:
- Karsten Lentzsch
- See Also:
FormLayout,ColumnSpec
-
-
Field Summary
Fields Modifier and Type Field Description static ColumnSpecBUTTON_COLSPECDescribes a logical horizontal column for a fixed size button.static ColumnSpecDEFAULT_COLSPECAn unmodifyableColumnSpecthat determines its preferred width by computing the maximum of all column component preferred widths and its minimum width by computing all column component minimum widths.static RowSpecDEFAULT_ROWSPECAn unmodifyableRowSpecthat determines its preferred height by computing the maximum of all column component preferred heights and its minimum height by computing all column component minimum heights.static ColumnSpecGLUE_COLSPECAn unmodifyableColumnSpecthat has an initial width of 0 pixels and that grows.static RowSpecGLUE_ROWSPECAn unmodifyableRowSpecthat has an initial height of 0 pixels and that grows.static ColumnSpecGROWING_BUTTON_COLSPECDescribes a logical horizontal column for a growing button.static ColumnSpecLABEL_COMPONENT_GAP_COLSPECDescribes a logical horizontal gap between a label and an associated component.static RowSpecLINE_GAP_ROWSPECDescribes the logical vertical default gap between two rows in the grid.static ColumnSpecMIN_COLSPECAn unmodifyableColumnSpecthat determines its width by computing the maximum of all column component minimum widths.static RowSpecMIN_ROWSPECAn unmodifyableRowSpecthat determines its height by computing the maximum of all column component minimum heights.static RowSpecNARROW_LINE_GAP_ROWSPECDescribes a logical vertical narrow gap between two rows in the grid.static RowSpecPARAGRAPH_GAP_ROWSPECDescribes the logical vertical default gap between two paragraphs in the layout grid.static ColumnSpecPREF_COLSPECAn unmodifyableColumnSpecthat determines its width by computing the maximum of all column component preferred widths.static RowSpecPREF_ROWSPECAn unmodifyableRowSpecthat determines its height by computing the maximum of all column component preferred heights.static ColumnSpecRELATED_GAP_COLSPECDescribes a logical horizontal gap between two related components.static RowSpecRELATED_GAP_ROWSPECDescribes a logical vertical gap between two related components.static ColumnSpecUNRELATED_GAP_COLSPECDescribes a logical horizontal gap between two unrelated components.static RowSpecUNRELATED_GAP_ROWSPECDescribes a logical vertical gap between two unrelated components.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FormLayoutcreateColumnLayout(int majorColumns, int minorColumns, ColumnSpec labelColumnSpec)Creates and returns an instance ofFormLayoutto build forms with the specified number of major and minor columns.static FormLayoutcreateColumnLayout(int majorColumns, int minorColumns, ColumnSpec labelColumnSpec, ColumnSpec componentColumnSpec, ConstantSize indent, ConstantSize majorColumnGap, ConstantSize minorColumnGap)Creates and returns an instance ofFormLayoutto build forms with the given number of major columns.static FormLayoutcreateColumnLayout(int majorColumns, int minorColumns, ColumnSpec labelColumnSpec, ConstantSize indent, ConstantSize minorColumnGap)Creates and returns an instance ofFormLayoutto build forms with the given number of major columns.static ColumnSpeccreateGapColumnSpec(ConstantSize gapSize)Creates and returns aColumnSpecthat represents a gap with the specifiedConstantSize.static RowSpeccreateGapRowSpec(ConstantSize gapSize)Creates and returns aRowSpecthat represents a gap with the specifiedConstantSize.
-
-
-
Field Detail
-
MIN_COLSPEC
public static final ColumnSpec MIN_COLSPEC
An unmodifyableColumnSpecthat determines its width by computing the maximum of all column component minimum widths.- See Also:
PREF_COLSPEC,DEFAULT_COLSPEC
-
PREF_COLSPEC
public static final ColumnSpec PREF_COLSPEC
An unmodifyableColumnSpecthat determines its width by computing the maximum of all column component preferred widths.- See Also:
MIN_COLSPEC,DEFAULT_COLSPEC
-
DEFAULT_COLSPEC
public static final ColumnSpec DEFAULT_COLSPEC
An unmodifyableColumnSpecthat determines its preferred width by computing the maximum of all column component preferred widths and its minimum width by computing all column component minimum widths.Useful to let a column shrink from preferred width to minimum width if the container space gets scarce.
- See Also:
MIN_COLSPEC,PREF_COLSPEC
-
GLUE_COLSPEC
public static final ColumnSpec GLUE_COLSPEC
An unmodifyableColumnSpecthat has an initial width of 0 pixels and that grows. Useful to describe glue columns that fill the space between other columns.- See Also:
GLUE_ROWSPEC
-
LABEL_COMPONENT_GAP_COLSPEC
public static final ColumnSpec LABEL_COMPONENT_GAP_COLSPEC
Describes a logical horizontal gap between a label and an associated component. Useful for builders that automatically fill a grid with labels and components.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- Since:
- 1.0.3
-
RELATED_GAP_COLSPEC
public static final ColumnSpec RELATED_GAP_COLSPEC
Describes a logical horizontal gap between two related components. For example the OK and Cancel buttons are considered related.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
UNRELATED_GAP_COLSPEC
-
UNRELATED_GAP_COLSPEC
public static final ColumnSpec UNRELATED_GAP_COLSPEC
Describes a logical horizontal gap between two unrelated components.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
RELATED_GAP_COLSPEC
-
BUTTON_COLSPEC
public static final ColumnSpec BUTTON_COLSPEC
Describes a logical horizontal column for a fixed size button. This spec honors the current layout style's default button minimum width.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
GROWING_BUTTON_COLSPEC
-
GROWING_BUTTON_COLSPEC
public static final ColumnSpec GROWING_BUTTON_COLSPEC
Describes a logical horizontal column for a growing button. This spec does not use the layout style's default button minimum width.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
BUTTON_COLSPEC
-
MIN_ROWSPEC
public static final RowSpec MIN_ROWSPEC
An unmodifyableRowSpecthat determines its height by computing the maximum of all column component minimum heights.- See Also:
PREF_ROWSPEC,DEFAULT_ROWSPEC
-
PREF_ROWSPEC
public static final RowSpec PREF_ROWSPEC
An unmodifyableRowSpecthat determines its height by computing the maximum of all column component preferred heights.- See Also:
MIN_ROWSPEC,DEFAULT_ROWSPEC
-
DEFAULT_ROWSPEC
public static final RowSpec DEFAULT_ROWSPEC
An unmodifyableRowSpecthat determines its preferred height by computing the maximum of all column component preferred heights and its minimum height by computing all column component minimum heights.Useful to let a column shrink from preferred height to minimum height if the container space gets scarce.
- See Also:
MIN_COLSPEC,PREF_COLSPEC
-
GLUE_ROWSPEC
public static final RowSpec GLUE_ROWSPEC
An unmodifyableRowSpecthat has an initial height of 0 pixels and that grows. Useful to describe glue rows that fill the space between other rows.- See Also:
GLUE_COLSPEC
-
RELATED_GAP_ROWSPEC
public static final RowSpec RELATED_GAP_ROWSPEC
Describes a logical vertical gap between two related components. For example the OK and Cancel buttons are considered related.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
UNRELATED_GAP_ROWSPEC
-
UNRELATED_GAP_ROWSPEC
public static final RowSpec UNRELATED_GAP_ROWSPEC
Describes a logical vertical gap between two unrelated components.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
RELATED_GAP_ROWSPEC
-
NARROW_LINE_GAP_ROWSPEC
public static final RowSpec NARROW_LINE_GAP_ROWSPEC
Describes a logical vertical narrow gap between two rows in the grid. Useful if the vertical space is scarce or if an individual vertical gap shall be small than the default line gap.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
LINE_GAP_ROWSPEC,PARAGRAPH_GAP_ROWSPEC
-
LINE_GAP_ROWSPEC
public static final RowSpec LINE_GAP_ROWSPEC
Describes the logical vertical default gap between two rows in the grid. A little bit larger than the narrow line gap.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
NARROW_LINE_GAP_ROWSPEC,PARAGRAPH_GAP_ROWSPEC
-
PARAGRAPH_GAP_ROWSPEC
public static final RowSpec PARAGRAPH_GAP_ROWSPEC
Describes the logical vertical default gap between two paragraphs in the layout grid. This gap is larger than the default line gap.Note: In a future version this constant will likely be moved to a class
LogicalSizeorStyledSize.- See Also:
NARROW_LINE_GAP_ROWSPEC,LINE_GAP_ROWSPEC
-
-
Method Detail
-
createColumnLayout
public static FormLayout createColumnLayout(int majorColumns, int minorColumns, ColumnSpec labelColumnSpec)
Creates and returns an instance ofFormLayoutto build forms with the specified number of major and minor columns.The layout will use default values for all gaps.
This method may be removed from a future version.
- Parameters:
majorColumns- the number of used major columnsminorColumns- the number of used minor columnslabelColumnSpec- specifies the label columns- Returns:
- a prepared
FormLayout
-
createColumnLayout
public static FormLayout createColumnLayout(int majorColumns, int minorColumns, ColumnSpec labelColumnSpec, ConstantSize indent, ConstantSize minorColumnGap)
Creates and returns an instance ofFormLayoutto build forms with the given number of major columns. Major columns consists of a label and a component section, where each component section is divided into the given number of minor columns.The layout will use the specified gaps to separate major columns, and the label and component section.
This method may be removed from a future version.
- Parameters:
majorColumns- the number of major columnsminorColumns- the number of minor columnslabelColumnSpec- specifies the label columnsindent- an optionalConstantSizethat describes the width of the leading indent columnminorColumnGap- aConstantSizethat describes the gap between minor columns- Returns:
- a prepared
FormLayout
-
createColumnLayout
public static FormLayout createColumnLayout(int majorColumns, int minorColumns, ColumnSpec labelColumnSpec, ColumnSpec componentColumnSpec, ConstantSize indent, ConstantSize majorColumnGap, ConstantSize minorColumnGap)
Creates and returns an instance ofFormLayoutto build forms with the given number of major columns. Major columns consists of a label and a component section, where each component section is divided into the given number of minor columns.The layout will use the specified gaps to separate major columns, minor columns, and the label and component section.
This method may be removed from a future version.
- Parameters:
majorColumns- the number of major columnsminorColumns- the number of minor columnslabelColumnSpec- specifies the label columnscomponentColumnSpec- specifies the label columnsindent- an optionalConstantSizethat describes the width of the leading indent columnmajorColumnGap- aConstantSizethat describes the gap between major columnsminorColumnGap- aConstantSizethat describes the gap between minor columns- Returns:
- a prepared
FormLayout
-
createGapColumnSpec
public static ColumnSpec createGapColumnSpec(ConstantSize gapSize)
Creates and returns aColumnSpecthat represents a gap with the specifiedConstantSize.- Parameters:
gapSize- aConstantSizethat specifies the gap- Returns:
- a
ColumnSpecthat describes a horizontal gap
-
createGapRowSpec
public static RowSpec createGapRowSpec(ConstantSize gapSize)
Creates and returns aRowSpecthat represents a gap with the specifiedConstantSize.- Parameters:
gapSize- aConstantSizethat specifies the gap- Returns:
- a
RowSpecthat describes a vertical gap
-
-