public final class ButtonBarBuilder extends AbstractButtonPanelBuilder<ButtonBarBuilder>
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.
|
static ButtonBarBuilder |
create() |
add, appendColumn, appendGlueColumn, appendGlueRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, build, createButton, getColumn, getRow, isLeftToRight, nextColumn, nextRow, setBackground, setBorder, setLeftToRight, setOpaquebackground, border, border, createComponentFactory, getColumnCount, getComponentFactory, getContainer, getLayout, getPanel, getRowCount, opaque, padding, padding, 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 AbstractButtonPanelBuilder<ButtonBarBuilder>button - 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 AbstractButtonPanelBuilder<ButtonBarBuilder>buttons - the buttons to addAbstractButtonPanelBuilder.addButton(JComponent)public ButtonBarBuilder addButton(Action... actions)
AbstractButtonPanelBuilderaddButton in class AbstractButtonPanelBuilder<ButtonBarBuilder>actions - 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 AbstractButtonPanelBuilder<ButtonBarBuilder>LayoutStyle.getRelatedComponentsPadX()public ButtonBarBuilder addUnrelatedGap()
addUnrelatedGap in class AbstractButtonPanelBuilder<ButtonBarBuilder>LayoutStyle.getUnrelatedComponentsPadX()public ButtonBarBuilder addStrut(ConstantSize width)
addRelatedGap()
and addUnrelatedGap() respectively.width - describes the gap widthColumnSpec.createGap(ConstantSize)Copyright © 2002-2015 JGoodies Software GmbH. All Rights Reserved.