|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.forms.builder.AbstractBuilder
com.jgoodies.forms.builder.AbstractButtonPanelBuilder
com.jgoodies.forms.builder.ButtonBarBuilder
public final class ButtonBarBuilder
A non-visual builder for building consistent button bars that comply
with popular style guides. Utilizes the JGoodies FormLayout
and honors the platform's LayoutStyle
regarding button sizes,
and gaps.
Examples:
// 1) Build and return a bar with three related buttons return new ButtonBarBuilder() .addButton(newButton) .addRelatedGap() .addButton(editButton) .addRelatedGap() .addButton(deleteButton) .build(); // 2) Short hand for example 1) return new ButtonBarBuilder() .addButton(newButton, editButton, deleteButton) .build(); // 3) Build and return a bar with two sections return new ButtonBarBuilder() .addButton(newButton, editButton, deleteButton) .addUnrelatedGap() .addButton(moveUpButton, moveDownButton) .build(); // 4) Short hand for example 3) return new ButtonBarBuilder() .addButton(newButton, editButton, deleteButton, null, moveUpButton, moveDownButton) .build(); // 5) Build and return a complex button bar return new ButtonBarBuilder() .addButton(newButton, editButton, deleteButton) .addUnrelatedGap() .addButton(moveUpButton, moveDownButton) .addGlue() .addGrowing(legendComponent) .build();
ButtonStackBuilder
,
LayoutStyle
Field Summary |
---|
Fields inherited from class com.jgoodies.forms.builder.AbstractButtonPanelBuilder |
---|
focusGrouped |
Fields inherited from class com.jgoodies.forms.builder.AbstractBuilder |
---|
currentCellConstraints |
Constructor Summary | |
---|---|
ButtonBarBuilder()
Constructs an empty ButtonBarBuilder on a JPanel. |
|
ButtonBarBuilder(JPanel panel)
Constructs an empty ButtonBarBuilder on the given panel. |
Method Summary | |
---|---|
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. |
ButtonBarBuilder |
opaque(boolean b)
Sets the panel's opaque state. |
Methods inherited from class com.jgoodies.forms.builder.AbstractButtonPanelBuilder |
---|
add, appendColumn, appendGlueColumn, appendGlueRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, build, createButton, getColumn, getPanel, getRow, isLeftToRight, nextColumn, nextRow, setBackground, setBorder, setLeftToRight, setOpaque |
Methods inherited from class com.jgoodies.forms.builder.AbstractBuilder |
---|
createComponentFactory, getColumnCount, getComponentFactory, getComponentFactoryDefault, getContainer, getLayout, getRowCount, setComponentFactory, setComponentFactoryDefault |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ButtonBarBuilder()
public ButtonBarBuilder(JPanel panel)
panel
- the layout containerMethod Detail |
---|
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
button
- the component to add
NullPointerException
- if button
is null
public ButtonBarBuilder addButton(JComponent... buttons)
AbstractButtonPanelBuilder
null
. 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
buttons
- the buttons to add
AbstractButtonPanelBuilder.addButton(JComponent)
public ButtonBarBuilder addButton(Action... actions)
AbstractButtonPanelBuilder
addButton
in class AbstractButtonPanelBuilder
actions
- an array of buttons to addpublic ButtonBarBuilder addFixed(JComponent component)
component
- the component to add
public ButtonBarBuilder addGrowing(JComponent component)
LayoutStyle.getDefaultButtonWidth()
.
component
- the component to add
public ButtonBarBuilder addGlue()
public ButtonBarBuilder addRelatedGap()
addRelatedGap
in class AbstractButtonPanelBuilder
LayoutStyle.getRelatedComponentsPadX()
public ButtonBarBuilder addUnrelatedGap()
addUnrelatedGap
in class AbstractButtonPanelBuilder
LayoutStyle.getUnrelatedComponentsPadX()
public ButtonBarBuilder addStrut(ConstantSize width)
addRelatedGap()
and addUnrelatedGap()
respectively.
width
- describes the gap width
ColumnSpec.createGap(ConstantSize)
public ButtonBarBuilder background(Color background)
AbstractButtonPanelBuilder
background
in class AbstractButtonPanelBuilder
background
- the color to set as new backgroundJComponent.setBackground(Color)
public ButtonBarBuilder border(Border border)
AbstractButtonPanelBuilder
border
in class AbstractButtonPanelBuilder
border
- the border to setJComponent.setBorder(Border)
public ButtonBarBuilder opaque(boolean b)
AbstractButtonPanelBuilder
opaque
in class AbstractButtonPanelBuilder
b
- true for opaque, false for non-opaqueJComponent.setOpaque(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |