public final class ButtonBarBuilder extends AbstractButtonPanelBuilder
FormLayout and honors the platform's
LayoutStyle regarding button sizes, and gaps.Examples:
// 1) Build and return a bar with three related buttons
return ButtonBarBuilder.create()
.addButton(newButton)
.addRelatedGap()
.addButton(editButton)
.addRelatedGap()
.addButton(deleteButton)
.build();
// 2) Short hand for example 1)
return ButtonBarBuilder.create()
.addButton(newButton, editButton, deleteButton)
.build();
// 3) Build and return a bar with two sections
return ButtonBarBuilder.create()
.addButton(newButton, editButton, deleteButton)
.addUnrelatedGap()
.addButton(moveUpButton, moveDownButton)
.build();
// 4) Short hand for example 3)
return ButtonBarBuilder.create()
.addButton(newButton, editButton, deleteButton,
null,
moveUpButton, moveDownButton)
.build();
// 5) Build and return a complex button bar
return ButtonBarBuilder.create()
.addButton(newButton, editButton, deleteButton)
.addUnrelatedGap()
.addButton(moveUpButton, moveDownButton)
.addGlue()
.addGrowing(legendComponent)
.build();
ButtonStackBuilder,
LayoutStylefocusGroupedcurrentCellConstraints| Constructor and Description |
|---|
ButtonBarBuilder()
Constructs an empty ButtonBarBuilder on a JPanel.
|
ButtonBarBuilder(JPanel panel)
Constructs an empty ButtonBarBuilder on the given panel.
|
| Modifier and Type | Method and Description |
|---|---|
ButtonBarBuilder |
addButton(Action... actions)
Constructs an array of JButtons from the given Action array,
and adds them as a sequence of related buttons separated by a default gap.
|
ButtonBarBuilder |
addButton(JComponent... buttons)
Adds one or many sequences of related buttons.
|
ButtonBarBuilder |
addButton(JComponent button)
Adds a button component that has a minimum width
specified by the
LayoutStyle.getDefaultButtonWidth(). |
ButtonBarBuilder |
addFixed(JComponent component)
Adds a fixed size component with narrow margin.
|
ButtonBarBuilder |
addGlue()
Adds a glue that will be given the extra space,
if this button bar is larger than its preferred size.
|
ButtonBarBuilder |
addGrowing(JComponent component)
Adds a component that grows if the container grows.
|
ButtonBarBuilder |
addRelatedGap()
Adds the standard horizontal gap for related components.
|
ButtonBarBuilder |
addStrut(ConstantSize width)
Adds a horizontal strut of the specified width.
|
ButtonBarBuilder |
addUnrelatedGap()
Adds the standard horizontal gap for unrelated components.
|
ButtonBarBuilder |
background(Color background)
Sets the panel's background color and makes the panel opaque.
|
ButtonBarBuilder |
border(Border border)
Sets the panel's border.
|
static ButtonBarBuilder |
create() |
ButtonBarBuilder |
opaque(boolean b)
Sets the panel's opaque state.
|
add, appendColumn, appendGlueColumn, appendGlueRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, build, createButton, getColumn, getPanel, getRow, isLeftToRight, nextColumn, nextRow, setBackground, setBorder, setLeftToRight, setOpaquecreateComponentFactory, getColumnCount, getComponentFactory, getContainer, getLayout, getRowCount, setComponentFactorypublic ButtonBarBuilder()
public ButtonBarBuilder(JPanel panel)
panel - the layout containerpublic static ButtonBarBuilder create()
public ButtonBarBuilder addButton(JComponent button)
LayoutStyle.getDefaultButtonWidth().Although a JButton is expected, any JComponent is accepted to allow custom button component types.
addButton in class AbstractButtonPanelBuilderbutton - the component to addNullPointerException - if button is nullpublic ButtonBarBuilder addButton(JComponent... buttons)
AbstractButtonPanelBuildernull. The next sequence is separated by an
unrelated gap.
Each button has the minimum width as specified by
LayoutStyle.getDefaultButtonWidth(). The gap width between
the buttons is LayoutStyle.getRelatedComponentsPadX().Although JButtons are expected, general JComponents are accepted to allow custom button component types.
Examples:
builder.addButtons(newButton, editButton, deleteButton); builder.addButtons(newButton, editButton, deleteButton, null, printButton);
addButton in class AbstractButtonPanelBuilderbuttons - the buttons to addAbstractButtonPanelBuilder.addButton(JComponent)public ButtonBarBuilder addButton(Action... actions)
AbstractButtonPanelBuilderaddButton in class AbstractButtonPanelBuilderactions - an array of buttons to addpublic ButtonBarBuilder addFixed(JComponent component)
component - the component to addpublic ButtonBarBuilder addGrowing(JComponent component)
LayoutStyle.getDefaultButtonWidth().component - the component to addpublic ButtonBarBuilder addGlue()
public ButtonBarBuilder addRelatedGap()
addRelatedGap in class AbstractButtonPanelBuilderLayoutStyle.getRelatedComponentsPadX()public ButtonBarBuilder addUnrelatedGap()
addUnrelatedGap in class AbstractButtonPanelBuilderLayoutStyle.getUnrelatedComponentsPadX()public ButtonBarBuilder addStrut(ConstantSize width)
addRelatedGap()
and addUnrelatedGap() respectively.width - describes the gap widthColumnSpec.createGap(ConstantSize)public ButtonBarBuilder background(Color background)
AbstractButtonPanelBuilderbackground in class AbstractButtonPanelBuilderbackground - the color to set as new backgroundJComponent.setBackground(Color)public ButtonBarBuilder border(Border border)
AbstractButtonPanelBuilderborder in class AbstractButtonPanelBuilderborder - the border to setJComponent.setBorder(Border)public ButtonBarBuilder opaque(boolean b)
AbstractButtonPanelBuilderopaque in class AbstractButtonPanelBuilderb - true for opaque, false for non-opaqueJComponent.setOpaque(boolean)Copyright © 2002-2014 JGoodies Software GmbH. All Rights Reserved.