Package com.jgoodies.forms.internal
Class AbstractBuilder<B extends AbstractBuilder<B>>
java.lang.Object
com.jgoodies.forms.internal.AbstractBuilder<B>
- Type Parameters:
B
- the type of the builder, e.g. ButtonBarBuilder
- Direct Known Subclasses:
AbstractButtonPanelBuilder
,AbstractFormBuilder
An abstract class that minimizes the effort required to implement
non-visual builders that use the
FormLayout
.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 $
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ComponentFactory
Refers to a factory that is used to create labels, titles, separators, and buttons.protected final CellConstraints
Holds an instance ofCellConstraints
that will be used to specify the location, extent and alignments of the component to be added next.private final FormLayout
Holds the FormLayout instance that is used to specify, fill and layout this form.private final JPanel
Holds the layout container that we are building. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractBuilder
(FormLayout layout, JPanel panel) Constructs an AbstractBuilder for the given layout and panel. -
Method Summary
Modifier and TypeMethodDescriptionbackground
(Color background) Sets the panel's background color and makes the panel opaque.Deprecated.Sets the panel's border.abstract JPanel
build()
protected ComponentFactory
Invoked when the per-instance component factory is lazily initialized.final int
Returns the number of columns in the form.final ComponentFactory
Returns this builder's component factory.final Container
Deprecated.Replaced bygetPanel()
final FormLayout
Returns the FormLayout instance used to build this form.final JPanel
getPanel()
Returns the panel used to build the form.final int
Returns the number of rows in the form.opaque
(boolean b) Sets the panel's opaque state.Sets the panel's padding as an EmptyBorder using the given specification for the top, left, bottom, right margins in DLU.padding
(EmptyBorder padding) Sets a padding around this builder's panel.final void
setComponentFactory
(ComponentFactory newFactory) Sets a new component factory for this builder, overriding the default as provided byFormsSetup.getComponentFactoryDefault()
.
-
Field Details
-
panel
Holds the layout container that we are building. -
layout
Holds the FormLayout instance that is used to specify, fill and layout this form. -
currentCellConstraints
Holds an instance ofCellConstraints
that will be used to specify the location, extent and alignments of the component to be added next. -
componentFactory
Refers to a factory that is used to create labels, titles, separators, and buttons.
-
-
Constructor Details
-
AbstractBuilder
Constructs an AbstractBuilder for the given layout and panel.- Parameters:
layout
- the FormLayout to usepanel
- the layout container- Throws:
NullPointerException
- iflayout
orpanel
isnull
-
-
Method Details
-
getPanel
Returns the panel used to build the form. Intended to access panel properties. For returning the built panel, you should usebuild()
.- Returns:
- the panel used by this builder to build the form
-
build
-
getContainer
Deprecated.Replaced bygetPanel()
Returns the container used to build the form.- Returns:
- the layout container
-
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
-
background
Sets the panel's background color and makes the panel opaque.- Parameters:
background
- the color to set as new background- See Also:
-
border
Sets the panel's border.- Parameters:
border
- the border to set- See Also:
-
border
Deprecated.Replaced bypadding(String, Object...)
Sets the panel's border as an EmptyBorder using the given specification for the top, left, bottom, right in DLU. For example "1dlu, 2dlu, 3dlu, 4dlu" sets an empty border with 1dlu in the top, 2dlu in the left side, 3dlu at the bottom, and 4dlu in the right hand side.Equivalent to
padding(Paddings.createPadding(paddingSpec))
.- Parameters:
paddingSpec
- describes the top, left, bottom, right sizes of the EmptyBorder to create- Since:
- 1.6
- See Also:
-
padding
Sets a padding around this builder's panel.- Parameters:
padding
- the empty border to set- Since:
- 1.9
- See Also:
-
padding
Sets the panel's padding as an EmptyBorder using the given specification for the top, left, bottom, right margins in DLU. For example "1dlu, 2dlu, 3dlu, 4dlu" sets an empty border with 1dlu in the top, 2dlu in the left side, 3dlu at the bottom, and 4dlu in the right hand side.Equivalent to
setPadding(Paddings.createPadding(paddingSpec))
.- Parameters:
paddingSpec
- describes the top, left, bottom, right margins of the padding (an EmptyBorder) to useargs
- optional format arguments, used ifpaddingSpec
is a format string- Returns:
- a reference to this builder
- Since:
- 1.9
- See Also:
-
opaque
Sets the panel's opaque state.- Parameters:
b
- true for opaque, false for non-opaque- See Also:
-
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
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:
-
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
-
padding(String, Object...)