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 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 $
  Author:
    Karsten Lentzsch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected 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.

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractBuilder(FormLayout layout, JPanel panel)` Constructs an AbstractBuilder for the given layout and panel.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `B` | `background(Color background)` Sets the panel's background color and makes the panel opaque.
    `B` | `border(Border border)` Sets the panel's border.
    `B` | `border(String paddingSpec)` Deprecated. Replaced by `padding(String, Object...)`
    `abstract 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.
    `Container` | `getContainer()` Deprecated. Replaced by `getPanel()`
    `FormLayout` | `getLayout()` Returns the FormLayout instance used to build this form.
    `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(EmptyBorder padding)` Sets a padding around this builder's panel.
    `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.
    `void` | `setComponentFactory(ComponentFactory newFactory)` Sets a new component factory for this builder, overriding the default as provided by `FormsSetup.getComponentFactoryDefault()`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### 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.

  - ### Constructor Detail

    - #### 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 Detail

    - #### 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:
        `JComponent.setBackground(Color)`

    - #### border

          public B border(Border border)

      Sets the panel's border.
      Parameters:
        `border` - the border to set
      See Also:
        `JComponent.setBorder(Border)`

    - #### border

          @Deprecated
          public B border(String paddingSpec)

      Deprecated. Replaced by `padding(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(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(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:
        `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 by `FormsSetup.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 by `FormsSetup.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

Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.