public final class ButtonStackBuilder extends PanelBuilder
FormLayout.This builder sets a hint for narrow margin for the gridded buttons. This can reduce the button stack's width if some buttons have long texts. For example, a stack with 'OK', 'Cancel', 'Configure…' will likely exceed the minimum button width. The narrow margins help getting narrow stacks. Note that some look&feels do not support the narrow margin feature, and conversely, others have only narrow margins. The JGoodies look&feels honor the setting, the Mac Aqua l&f uses narrow margins all the time.
Example:
The following example builds a button stack with Close, Up and
Down, where Up and Down are related, and Close is not related
to the other buttons, which makes a wide gap for the unrelated and
a smaller gap for the related buttons.
private JPanel createCloseUpDownButtonStack(
JButton close, JButton up, JButton down) {
ButtonStackBuilder builder = new ButtonStackBuilder();
builder.addGridded(close);
builder.addUnrelatedGap();
builder.addGridded(up);
builder.addRelatedGap();
builder.addGridded(down);
return builder.getPanel();
}
ButtonBarBuilder2,
ButtonBarFactory,
LayoutStylecurrentCellConstraints| Constructor and Description |
|---|
ButtonStackBuilder()
Constructs a ButtonStackBuilder on a default JPanel
using a preconfigured FormLayout as layout manager.
|
ButtonStackBuilder(FormLayout layout,
JPanel panel)
Constructs a ButtonStackBuilder on the given panel and layout.
|
ButtonStackBuilder(JPanel panel)
Constructs a ButtonStackBuilder on the given panel
using a preconfigured FormLayout as layout manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
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.
|
void |
addButton(JButton... buttons)
Adds a sequence of related buttons separated by a default gap.
|
void |
addButtons(JButton[] buttons)
Adds a sequence of related buttons separated by a default gap.
|
void |
addFixed(JComponent component)
Adds a fixed size component.
|
void |
addGlue()
Adds a glue that will be given the extra space,
if this box is larger than its preferred size.
|
void |
addGridded(JComponent component)
Adds a gridded component.
|
void |
addRelatedGap()
Adds the standard gap for related components.
|
void |
addStrut(ConstantSize size)
Adds a strut of a specified size.
|
void |
addUnrelatedGap()
Adds the standard gap for unrelated components.
|
add, add, addLabel, addLabel, addLabel, addLabel, addROLabel, addROLabel, addROLabel, addROLabel, addSeparator, addSeparator, addSeparator, addSeparator, addTitle, addTitle, addTitle, getLabelForFeatureEnabledDefault, getPanel, isLabelForApplicable, isLabelForFeatureEnabled, setBackground, setBorder, setDefaultDialogBorder, setLabelFor, setLabelForFeatureEnabled, setLabelForFeatureEnabledDefault, setOpaqueadd, add, appendColumn, appendColumn, appendGlueColumn, appendGlueRow, appendLabelComponentsGapColumn, appendParagraphGapRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, cellConstraints, createLeftAdjustedConstraints, getColumn, getColumnIncrementSign, getLeadingColumn, getRow, isLeftToRight, nextColumn, nextColumn, nextLine, nextLine, nextRow, nextRow, setAlignment, setBounds, setColumn, setColumnSpan, setExtent, setHAlignment, setLeftToRight, setOrigin, setRow, setRowSpan, setVAlignmentcreateComponentFactory, getColumnCount, getComponentFactory, getContainer, getDefaultComponentFactory, getLayout, getRowCount, setComponentFactory, setDefaultComponentFactorypublic ButtonStackBuilder()
public ButtonStackBuilder(JPanel panel)
panel - the layout containerpublic ButtonStackBuilder(FormLayout layout, JPanel panel)
layout - the FormLayout used to layoutpanel - the layout containerpublic void addButtons(JButton[] buttons)
buttons - an array of buttons to addpublic void addFixed(JComponent component)
component - the component to addpublic void addGridded(JComponent component)
component - the component to addpublic void addGlue()
public void addRelatedGap()
public void addUnrelatedGap()
public void addStrut(ConstantSize size)
size - a constant that describes the gappublic void addButton(JButton... buttons)
buttons - the array of buttons to addpublic void addButton(Action... actions)
actions - an array of buttons to addCopyright © 2012 JGoodies. All Rights Reserved.