Package com.jgoodies.forms.builder
Class AbstractBuilder
- java.lang.Object
-
- com.jgoodies.forms.builder.AbstractBuilder
-
- Direct Known Subclasses:
AbstractButtonPanelBuilder
,AbstractFormBuilder
public abstract class AbstractBuilder extends java.lang.Object
An abstract class that minimizes the effort required to implement non-visual builders that use theFormLayout
.Builders hide details of the FormLayout and provide convenience behavior that assists you in constructing a form, bar, stack. This class provides a cell cursor that helps you traverse a form while you add components. Also, it offers several methods to append custom and logical columns and rows.
- Version:
- $Revision: 1.3 $
- See Also:
ButtonBarBuilder
,ButtonStackBuilder
,PanelBuilder
,I15dPanelBuilder
,DefaultFormBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private ComponentFactory
componentFactory
Refers to a factory that is used to create labels, titles, separators, and buttons.private java.awt.Container
container
Holds the layout container that we are building.protected CellConstraints
currentCellConstraints
Holds an instance ofCellConstraints
that will be used to specify the location, extent and alignments of the component to be added next.private FormLayout
layout
Holds the FormLayout instance that is used to specify, fill and layout this form.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBuilder(FormLayout layout, java.awt.Container container)
Constructs an AbstractBuilder for the given FormLayout and layout container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ComponentFactory
createComponentFactory()
Invoked when the per-instance component factory is lazily initialized.int
getColumnCount()
Returns the number of columns in the form.ComponentFactory
getComponentFactory()
Returns this builder's component factory.java.awt.Container
getContainer()
Returns the container used to build the form.FormLayout
getLayout()
Returns the FormLayout instance used to build this form.int
getRowCount()
Returns the number of rows in the form.void
setComponentFactory(ComponentFactory newFactory)
Sets a new component factory for this builder, overriding the default as provided byFormsSetup.getComponentFactoryDefault()
.
-
-
-
Field Detail
-
container
private final java.awt.Container container
Holds the layout container that we are building.
-
layout
private final FormLayout layout
Holds the FormLayout instance that is used to specify, fill and layout this form.
-
currentCellConstraints
protected final CellConstraints currentCellConstraints
Holds an instance ofCellConstraints
that will be used to specify the location, extent and alignments of the component to be added next.
-
componentFactory
private ComponentFactory componentFactory
Refers to a factory that is used to create labels, titles, separators, and buttons.
-
-
Constructor Detail
-
AbstractBuilder
protected AbstractBuilder(FormLayout layout, java.awt.Container container)
Constructs an AbstractBuilder for the given FormLayout and layout container.- Parameters:
layout
- the FormLayout to usecontainer
- the layout container- Throws:
java.lang.NullPointerException
- iflayout
orcontainer
isnull
-
-
Method Detail
-
getContainer
public final java.awt.Container getContainer()
Returns the container used to build the form.- Returns:
- the layout container
-
getLayout
public final FormLayout getLayout()
Returns the FormLayout instance used to build this form.- Returns:
- the FormLayout
-
getColumnCount
public final int getColumnCount()
Returns the number of columns in the form.- Returns:
- the number of columns
-
getRowCount
public final int getRowCount()
Returns the number of rows in the form.- Returns:
- the number of rows
-
getComponentFactory
public final ComponentFactory getComponentFactory()
Returns this builder's component factory. If no factory has been set before, it is lazily initialized from the global default as returned byFormsSetup.getComponentFactoryDefault()
.- Returns:
- the component factory
- See Also:
setComponentFactory(ComponentFactory)
-
setComponentFactory
public final void setComponentFactory(ComponentFactory newFactory)
Sets a new component factory for this builder, overriding the default as provided byFormsSetup.getComponentFactoryDefault()
.- Parameters:
newFactory
- the component factory to be used for this builder- See Also:
getComponentFactory()
-
createComponentFactory
protected ComponentFactory createComponentFactory()
Invoked when the per-instance component factory is lazily initialized. This implementation returns the global default factory.Subclasses may override to use a factory other than the global default. However, in most cases it is sufficient to just set a new global default using
FormsSetup.setComponentFactoryDefault(ComponentFactory)
.- Returns:
- the factory used during the lazy initialization of the per-instance component factory
-
-