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
public abstract class AbstractBuilder<B extends AbstractBuilder<B>> 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 $
-
-
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.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.private javax.swing.JPanel
panel
Holds the layout container that we are building.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBuilder(FormLayout layout, javax.swing.JPanel panel)
Constructs an AbstractBuilder for the given layout and panel.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description B
background(java.awt.Color background)
Sets the panel's background color and makes the panel opaque.B
border(java.lang.String paddingSpec)
Deprecated.Replaced bypadding(String, Object...)
B
border(javax.swing.border.Border border)
Sets the panel's border.abstract javax.swing.JPanel
build()
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()
Deprecated.Replaced bygetPanel()
FormLayout
getLayout()
Returns the FormLayout instance used to build this form.javax.swing.JPanel
getPanel()
Returns the panel used to build the form.int
getRowCount()
Returns the number of rows in the form.B
opaque(boolean b)
Sets the panel's opaque state.B
padding(java.lang.String paddingSpec, java.lang.Object... args)
Sets the panel's padding as an EmptyBorder using the given specification for the top, left, bottom, right margins in DLU.B
padding(javax.swing.border.EmptyBorder padding)
Sets a padding around this builder's panel.void
setComponentFactory(ComponentFactory newFactory)
Sets a new component factory for this builder, overriding the default as provided byFormsSetup.getComponentFactoryDefault()
.
-
-
-
Field Detail
-
panel
private final javax.swing.JPanel panel
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, javax.swing.JPanel panel)
Constructs an AbstractBuilder for the given layout and panel.- Parameters:
layout
- the FormLayout to usepanel
- the layout container- Throws:
java.lang.NullPointerException
- iflayout
orpanel
isnull
-
-
Method Detail
-
getPanel
public final javax.swing.JPanel 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
public abstract javax.swing.JPanel build()
-
getContainer
@Deprecated public final java.awt.Container getContainer()
Deprecated.Replaced bygetPanel()
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
-
background
public B background(java.awt.Color background)
Sets the panel's background color and makes the panel opaque.- Parameters:
background
- the color to set as new background- See Also:
JComponent.setBackground(Color)
-
border
public B border(javax.swing.border.Border border)
Sets the panel's border.- Parameters:
border
- the border to set- See Also:
JComponent.setBorder(Border)
-
border
@Deprecated public B border(java.lang.String paddingSpec)
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:
Paddings.createPadding(String, Object...)
-
padding
public B padding(javax.swing.border.EmptyBorder padding)
Sets a padding around this builder's panel.- Parameters:
padding
- the empty border to set- Since:
- 1.9
- See Also:
JComponent.setBorder(Border)
-
padding
public B padding(java.lang.String paddingSpec, java.lang.Object... args)
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:
padding(EmptyBorder)
,Paddings.createPadding(String, Object...)
-
opaque
public B opaque(boolean b)
Sets the panel's opaque state.- Parameters:
b
- true for opaque, false for non-opaque- See Also:
JComponent.setOpaque(boolean)
-
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
-
-