Interface ControlPanelBuilder<C extends JComponent,B extends ControlPanelBuilder<C,B>>

Type Parameters:
C - the component type
B - the builder type
All Superinterfaces:
ComponentBuilder<C,B>, Supplier<C>
All Known Subinterfaces:
ButtonPanelBuilder, ToolBarBuilder

public interface ControlPanelBuilder<C extends JComponent,B extends ControlPanelBuilder<C,B>> extends ComponentBuilder<C,B>
Builds panels with buttons based on controls, along with any other components, in the order added.
JToolBar toolBar = Components.toolBar()
				.controls(navigationControls)
				.separator()
				.add(searchField)
				// the settings button aligned to the right
				.glue()
				.control(settingsControl)
				.floatable(false)
				.build();

The button configuration, such as includeButtonText(boolean) and buttons(Consumer), applies to the buttons based on the controls, components added via add(JComponent) are added as is.

Leading, trailing and adjacent duplicate separators are removed.

  • Method Details

    • action

      B action(Action action)
      Adds a button based on the given action, or a toggle button in case of a ToggleControl.
      Parameters:
      action - the action to add
      Returns:
      this builder instance
    • control

      B control(Control control)
      Adds a button based on the given control, or a toggle button in case of a ToggleControl.
      Parameters:
      control - the control to add
      Returns:
      this builder instance
    • control

      B control(Supplier<? extends Control> control)
      Adds a button based on the given control, or a toggle button in case of a ToggleControl.
      Parameters:
      control - the control to add
      Returns:
      this builder instance
    • controls

      B controls(Controls controls)
      Adds the actions of the given controls.
      Parameters:
      controls - the controls to add
      Returns:
      this builder instance
    • controls

      B controls(Supplier<Controls> controls)
      Adds the actions of the given controls.
      Parameters:
      controls - the controls to add
      Returns:
      this builder instance
    • separator

      B separator()
      Adds a separator.
      Returns:
      this builder instance
    • add

      B add(JComponent component)
      Adds the given component, as is.
      Parameters:
      component - the component to add
      Returns:
      this builder instance
    • add

      B add(Supplier<? extends JComponent> component)
      Adds the component provided by the given supplier when the panel is built, as is.
      Parameters:
      component - supplies the component to add
      Returns:
      this builder instance
    • orientation

      B orientation(int orientation)
      Parameters:
      orientation - the panel orientation, default SwingConstants.HORIZONTAL
      Returns:
      this builder instance
    • includeButtonText

      B includeButtonText(boolean includeButtonText)
      Parameters:
      includeButtonText - true if buttons should include text
      Returns:
      this builder instance
    • preferredButtonSize

      B preferredButtonSize(@Nullable Dimension preferredButtonSize)
      Parameters:
      preferredButtonSize - the preferred button size
      Returns:
      this builder instance
    • buttonsFocusable

      B buttonsFocusable(boolean buttonsFocusable)
      Parameters:
      buttonsFocusable - whether the buttons should be focusable, default is true
      Returns:
      this builder instance
    • toggleButtonType

      B toggleButtonType(ToggleButtonType toggleButtonType)
      Specifies how toggle controls are presented on this control panel. The default is ToggleButtonType.BUTTON.
      Parameters:
      toggleButtonType - the toggle button type
      Returns:
      this builder instance
    • buttons

      B buttons(Consumer<ButtonBuilder<?,?,?>> buttons)
      Configures each ButtonBuilder used to build the buttons.
      Parameters:
      buttons - receives the builder of each button
      Returns:
      this builder instance
    • toggleButtons

      B toggleButtons(Consumer<ToggleButtonBuilder<?,?>> toggleButtons)
      Configures each ToggleButtonBuilder used to build the toggle buttons, when toggle controls are presented as toggle buttons, see toggleButtonType(ToggleButtonType).
      Parameters:
      toggleButtons - receives the builder of each toggle button
      Returns:
      this builder instance
    • checkBoxes

      B checkBoxes(Consumer<CheckBoxBuilder> checkBoxes)
      Configures each CheckBoxBuilder used to build the check boxes, when toggle controls are presented as check boxes, see toggleButtonType(ToggleButtonType).
      Parameters:
      checkBoxes - receives the builder of each check box
      Returns:
      this builder instance
    • radioButtons

      B radioButtons(Consumer<RadioButtonBuilder> radioButtons)
      Configures each RadioButtonBuilder used to build the radio buttons, when toggle controls are presented as radio buttons, see toggleButtonType(ToggleButtonType).
      Parameters:
      radioButtons - receives the builder of each radio button
      Returns:
      this builder instance