Interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>

Type Parameters:
T - the type of the value the component represents
C - the component type
B - the builder type
All Known Subinterfaces:
BorderLayoutPanelBuilder, ButtonBuilder<T,C,B>, ButtonPanelBuilder, CheckBoxBuilder, CheckBoxMenuItemBuilder<B>, ComboBoxBuilder<T,C,B>, ControlPanelBuilder<C,B>, EntityComboBoxPanel.Builder, EntitySearchField.Builder, EntitySearchFieldPanel.Builder, FileInputPanel.Builder, FilteredTable.Builder<R,C>, ItemComboBoxBuilder<T>, ItemSpinnerBuilder<T>, LabelBuilder<T>, ListBuilder<T>, ListSpinnerBuilder<T>, MaskedTextFieldBuilder, MenuBuilder, MenuItemBuilder<C,B>, NumberField.Builder<T>, NumberSpinnerBuilder<T>, PanelBuilder, PasswordFieldBuilder, ProgressBarBuilder, RadioButtonBuilder, RadioButtonMenuItemBuilder<B>, ScrollPaneBuilder, SliderBuilder, SpinnerBuilder<T,B>, SplitPaneBuilder, TabbedPaneBuilder, TemporalField.Builder<T>, TemporalFieldPanel.Builder<T>, TextAreaBuilder, TextComponentBuilder<T,C,B>, TextFieldBuilder<T,C,B>, TextFieldPanel.Builder, ToggleButtonBuilder<C,B>, ToggleMenuItemBuilder<C,B>, ToolBarBuilder
All Known Implementing Classes:
AbstractComponentBuilder, DefaultComboBoxBuilder

public interface ComponentBuilder<T,C extends JComponent,B extends ComponentBuilder<T,C,B>>
Builds a JComponent.
Note that once build() or buildValue() have been called they will return the same instance on subsequent calls until the builder has been cleared by calling clear().
  • Field Details

    • TRANSFER_FOCUS_ON_ENTER

      static final PropertyValue<Boolean> TRANSFER_FOCUS_ON_ENTER
      Specifies whether focus should be transferred from components on enter.
      Note that for JTextArea CTRL is added to move focus forward
      Value type: Boolean
      Default value: false
  • Method Details

    • label

      B label(JLabel label)
      Parameters:
      label - the label for the component
      Returns:
      this builder instance
      See Also:
    • focusable

      B focusable(boolean focusable)
      Parameters:
      focusable - false if the component should not be focusable
      Returns:
      this builder instance
      See Also:
    • preferredHeight

      B preferredHeight(int preferredHeight)
      Parameters:
      preferredHeight - the preferred component height
      Returns:
      this builder instance
    • preferredWidth

      B preferredWidth(int preferredWidth)
      Parameters:
      preferredWidth - the preferred component width
      Returns:
      this builder instance
    • preferredSize

      B preferredSize(Dimension preferredSize)
      Parameters:
      preferredSize - the preferred component size
      Returns:
      this builder instance
      See Also:
    • maximumHeight

      B maximumHeight(int maximumHeight)
      Parameters:
      maximumHeight - the maximum component height
      Returns:
      this builder instance
    • maximumWidth

      B maximumWidth(int maximumWidth)
      Parameters:
      maximumWidth - the maximum component width
      Returns:
      this builder instance
    • maximumSize

      B maximumSize(Dimension maximumSize)
      Parameters:
      maximumSize - the maximum component size
      Returns:
      this builder instance
      See Also:
    • minimumHeight

      B minimumHeight(int minimumHeight)
      Parameters:
      minimumHeight - the minimum component height
      Returns:
      this builder instance
    • minimumWidth

      B minimumWidth(int minimumWidth)
      Parameters:
      minimumWidth - the minimum component width
      Returns:
      this builder instance
    • minimumSize

      B minimumSize(Dimension minimumSize)
      Parameters:
      minimumSize - the minimum component size
      Returns:
      this builder instance
      See Also:
    • border

      B border(Border border)
      Parameters:
      border - the component border
      Returns:
      this builder instance
      See Also:
    • transferFocusOnEnter

      B transferFocusOnEnter(boolean transferFocusOnEnter)
      Note that for JTextArea CTRL is added to move focus forward and CTRL + SHIFT to move it backwards
      Parameters:
      transferFocusOnEnter - if true then the text field transfer focus on enter (shift-enter for backwards)
      Returns:
      this builder instance
      See Also:
    • toolTipText

      B toolTipText(String toolTipText)
      Parameters:
      toolTipText - the tool tip text
      Returns:
      this builder instance
      See Also:
    • enabled

      B enabled(boolean enabled)
      Sets the enabled state of the component, for a dynamic enabled state use enabled(StateObserver). Overridden by enabled(StateObserver).
      Parameters:
      enabled - the enabled state
      Returns:
      this builder instance
      See Also:
    • enabled

      B enabled(StateObserver enabled)
      Parameters:
      enabled - the state observer controlling the component enabled status
      Returns:
      this builder instance
    • popupMenuControl

      B popupMenuControl(Function<C,Control> popupMenuControl)
      Parameters:
      popupMenuControl - a function, receiving the component being built, providing the control to base a popup menu on
      Returns:
      this builder instance
    • popupMenuControls

      B popupMenuControls(Function<C,Controls> popupMenuControls)
      Parameters:
      popupMenuControls - a function, receiving the component being built, providing the controls to base a popup menu on
      Returns:
      this builder instance
    • popupMenu

      B popupMenu(Function<C,JPopupMenu> popupMenu)
      Parameters:
      popupMenu - a function, receiving the component being built, providing the popup menu
      Returns:
      this builder instance
      See Also:
    • font

      B font(Font font)
      Parameters:
      font - the component font
      Returns:
      this builder instance
      See Also:
    • foreground

      B foreground(Color foreground)
      Parameters:
      foreground - the foreground color
      Returns:
      this builder instance
      See Also:
    • background

      B background(Color background)
      Parameters:
      background - the background color
      Returns:
      this builder instance
      See Also:
    • opaque

      B opaque(boolean opaque)
      Parameters:
      opaque - true if the component should be opaque
      Returns:
      this builder instance
      See Also:
    • visible

      B visible(boolean visible)
      Parameters:
      visible - the initial component visibility, default true
      Returns:
      this builder instance
      See Also:
    • componentOrientation

      B componentOrientation(ComponentOrientation orientation)
      Parameters:
      orientation - the component orientation
      Returns:
      this builder instance
      See Also:
    • validator

      B validator(Value.Validator<T> validator)
      Parameters:
      validator - the validator to use
      Returns:
      this builder instance
    • keyEvent

      B keyEvent(KeyEvents.Builder keyEventBuilder)
      Enables the key event defined by the given KeyEvents.Builder on the component. Note that setting transferFocusOnEnter(boolean) to true overrides any conflicting key event based on KeyEvent.VK_ENTER added via this method.
      Parameters:
      keyEventBuilder - a key event builder to enable on the component
      Returns:
      this builder instance
    • clientProperty

      B clientProperty(Object key, Object value)
      Adds an arbitrary key/value "client property" to the component
      Parameters:
      key - the key
      value - the value
      Returns:
      this builder instance
      See Also:
    • focusListener

      B focusListener(FocusListener focusListener)
      Parameters:
      focusListener - the focus listener
      Returns:
      this builder instance
      See Also:
    • mouseListener

      B mouseListener(MouseListener mouseListener)
      Parameters:
      mouseListener - the mouse listener
      Returns:
      this builder instance
      See Also:
    • mouseMotionListener

      B mouseMotionListener(MouseMotionListener mouseMotionListener)
      Parameters:
      mouseMotionListener - the mouse motion listener
      Returns:
      this builder instance
      See Also:
    • mouseWheelListener

      B mouseWheelListener(MouseWheelListener mouseWheelListener)
      Parameters:
      mouseWheelListener - the mouse wheel listener
      Returns:
      this builder instance
      See Also:
    • keyListener

      B keyListener(KeyListener keyListener)
      Parameters:
      keyListener - the key listener
      Returns:
      this builder instance
      See Also:
    • componentListener

      B componentListener(ComponentListener componentListener)
      Parameters:
      componentListener - the component listener
      Returns:
      this builder instance
      See Also:
    • propertyChangeListener

      B propertyChangeListener(PropertyChangeListener propertyChangeListener)
      Parameters:
      propertyChangeListener - the property change listener
      Returns:
      this builder instance
      See Also:
    • propertyChangeListener

      B propertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
      Parameters:
      propertyName - the name of the property to listen for
      propertyChangeListener - the property change listener
      Returns:
      this builder instance
      See Also:
    • transferHandler

      B transferHandler(TransferHandler transferHandler)
      Parameters:
      transferHandler - the transfer handler
      Returns:
      this builder instance
      See Also:
    • focusCycleRoot

      B focusCycleRoot(boolean focusCycleRoot)
      Parameters:
      focusCycleRoot - true if the component should be the root of a focus traversal cycle
      Returns:
      this builder instance
      See Also:
    • onSetVisible

      B onSetVisible(Consumer<C> onSetVisible)
      Parameters:
      onSetVisible - called when the component is made visible for the first time
      Returns:
      this builder instance
    • linkedValue

      B linkedValue(Value<T> linkedValue)
      Creates a bidirectional link to the given value. Overrides any initial value set.
      Parameters:
      linkedValue - a value to link to the component value
      Returns:
      this builder instance
    • linkedValue

      B linkedValue(ValueObserver<T> linkedValue)
      Creates a read-only link to the given ValueObserver.
      Parameters:
      linkedValue - a value to link to the component value
      Returns:
      this builder instance
    • initialValue

      B initialValue(T initialValue)
      Sets the initial value for the component, overridden by linkedValue(Value). Note that null is not explicitely set, the component is assumed to represent the null value right after it's been created.
      Parameters:
      initialValue - the initial value
      Returns:
      this builder instance
    • scrollPane

      ScrollPaneBuilder scrollPane()
      Returns:
      a ScrollPaneBuilder using this component as the view
    • onBuild

      B onBuild(Consumer<C> onBuild)
      Parameters:
      onBuild - called when the component has been built, not called on subsequent calls until clear() has been called.
      Returns:
      this builder instance
    • build

      C build()
      Builds and returns the component, note that subsequent calls return the same component until clear() has been called.
      Returns:
      the component
    • build

      C build(Consumer<C> onBuild)
      Builds and returns the component, note that subsequent calls return the same component until clear() has been called.
      Parameters:
      onBuild - called after the first call when the component is built, not called on subsequent calls.
      Returns:
      the component
    • clear

      B clear()
      Clears this builder so that it builds a new instance on next call to build() or buildValue().
      Returns:
      this builder instance
    • buildValue

      ComponentValue<T,C> buildValue()
      Builds and returns the component value, note that subsequent calls return the same component value until clear() has been called.
      Returns:
      the component value