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 Object
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 Details

    • panel

      private final 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 of CellConstraints 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 Details

    • AbstractBuilder

      protected AbstractBuilder(FormLayout layout, JPanel panel)
      Constructs an AbstractBuilder for the given layout and panel.
      Parameters:
      layout - the FormLayout to use
      panel - the layout container
      Throws:
      NullPointerException - if layout or panel is null
  • Method Details

    • getPanel

      public final JPanel getPanel()
      Returns the panel used to build the form. Intended to access panel properties. For returning the built panel, you should use build().
      Returns:
      the panel used by this builder to build the form
    • build

      public abstract JPanel build()
    • getContainer

      @Deprecated public final Container getContainer()
      Deprecated.
      Replaced by getPanel()
      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(Color background)
      Sets the panel's background color and makes the panel opaque.
      Parameters:
      background - the color to set as new background
      See Also:
    • border

      public B border(Border border)
      Sets the panel's border.
      Parameters:
      border - the border to set
      See Also:
    • border

      @Deprecated public B border(String paddingSpec)
      Deprecated.
      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

      public B padding(EmptyBorder padding)
      Sets a padding around this builder's panel.
      Parameters:
      padding - the empty border to set
      Since:
      1.9
      See Also:
    • padding

      public B padding(String paddingSpec, 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 use
      args - optional format arguments, used if paddingSpec is a format string
      Returns:
      a reference to this builder
      Since:
      1.9
      See Also:
    • opaque

      public B opaque(boolean b)
      Sets the panel's opaque state.
      Parameters:
      b - true for opaque, false for non-opaque
      See Also:
    • 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 by FormsSetup.getComponentFactoryDefault().
      Returns:
      the component factory
      See Also:
    • setComponentFactory

      public final void setComponentFactory(ComponentFactory newFactory)
      Sets a new component factory for this builder, overriding the default as provided by FormsSetup.getComponentFactoryDefault().
      Parameters:
      newFactory - the component factory to be used for this builder
      See Also:
    • 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