Class DefaultFormBuilder<B extends FormBuilder<B>>

java.lang.Object
is.codion.swing.common.ui.component.builder.AbstractComponentBuilder<JPanel,B>
is.codion.swing.common.ui.component.panel.DefaultFormBuilder<B>
Type Parameters:
B - the builder type
All Implemented Interfaces:
ComponentBuilder<JPanel,B>, FormBuilder<B>, Supplier<JPanel>
Direct Known Subclasses:
EditorComponents.ComponentFactory.AttributeFormBuilder

public class DefaultFormBuilder<B extends FormBuilder<B>> extends AbstractComponentBuilder<JPanel,B> implements FormBuilder<B>
A default FormBuilder implementation, extendable in order to add further ways of adding inputs.
  • Constructor Details

    • DefaultFormBuilder

      protected DefaultFormBuilder()
      Instantiates a new DefaultFormBuilder
  • Method Details

    • columns

      public final B columns(int columns)
      Specified by:
      columns in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      columns - the number of label/input pairs per row, default 1
      Returns:
      this builder instance
    • labelAlignment

      public final B labelAlignment(int labelAlignment)
      Specified by:
      labelAlignment in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      labelAlignment - the horizontal alignment of the labels within the label column, SwingConstants.LEADING (default) or SwingConstants.TRAILING
      Returns:
      this builder instance
    • add

      public final B add(JComponent component)
      Description copied from interface: FormBuilder
      Adds a label/input pair, the label being the one associated with the component via JLabel.setLabelFor(java.awt.Component), if any, otherwise the component occupies the input column alone, the label cell empty.
      Specified by:
      add in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      component - the input component
      Returns:
      this builder instance
    • add

      public final B add(Supplier<? extends JComponent> component)
      Description copied from interface: FormBuilder
      Adds a label/input pair, the label being the one associated with the component via JLabel.setLabelFor(java.awt.Component), if any, otherwise the component occupies the input column alone, the label cell empty.
      Specified by:
      add in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      component - the input component
      Returns:
      this builder instance
    • add

      public final B add(JComponent label, JComponent component)
      Description copied from interface: FormBuilder
      Adds a label/input pair. A JLabel carrying no association of its own is associated with the component, so that its mnemonic focuses it.
      Specified by:
      add in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      label - the label
      component - the input component
      Returns:
      this builder instance
    • add

      public final B add(Supplier<? extends JComponent> label, Supplier<? extends JComponent> component)
      Description copied from interface: FormBuilder
      Adds a label/input pair. A JLabel carrying no association of its own is associated with the component, so that its mnemonic focuses it.
      Specified by:
      add in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      label - the label
      component - the input component
      Returns:
      this builder instance
    • span

      public final B span(JComponent component)
      Description copied from interface: FormBuilder
      Adds a component occupying a row of its own. A label associated with the component keeps the label column, the component spanning the rest of the row, otherwise the component spans the full width.
      Specified by:
      span in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      component - the component
      Returns:
      this builder instance
    • span

      public final B span(Supplier<? extends JComponent> component)
      Description copied from interface: FormBuilder
      Adds a component occupying a row of its own. A label associated with the component keeps the label column, the component spanning the rest of the row, otherwise the component spans the full width.
      Specified by:
      span in interface FormBuilder<B extends FormBuilder<B>>
      Parameters:
      component - the component
      Returns:
      this builder instance
    • createComponent

      protected final JPanel createComponent()
      Description copied from class: AbstractComponentBuilder
      Creates the component.
      Specified by:
      createComponent in class AbstractComponentBuilder<JPanel,B extends FormBuilder<B>>
      Returns:
      a new component instance