Class AbstractBuilder<B extends 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 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 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 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 Detail

      • AbstractBuilder

        protected AbstractBuilder​(FormLayout layout,
                                  javax.swing.JPanel panel)
        Constructs an AbstractBuilder for the given layout and panel.
        Parameters:
        layout - the FormLayout to use
        panel - the layout container
        Throws:
        java.lang.NullPointerException - if layout or panel is null
    • 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 use build().
        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 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​(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.
        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 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)
      • 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