|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.forms.builder.AbstractFormBuilder
com.jgoodies.forms.builder.PanelBuilder
com.jgoodies.forms.builder.ButtonBarBuilder
public final class ButtonBarBuilder
A non-visual builder that assists you in building consistent button bars
that comply with popular UI style guides. It utilizes the FormLayout
.
This class is in turn used by the
ButtonBarFactory
that provides
an even higher level of abstraction for building consistent button bars.
Buttons added to the builder are either gridded or fixed and may fill
their FormLayout cell or not. All gridded buttons get the same width,
while fixed button use their own size. Gridded buttons honor
the default minimum button width as specified by the current
LayoutStyle
.
A button can optionally be declared as narrow, so that it has narrow margins if displayed with a JGoodies look&feel. This is useful if you want to layout buttons with equal width even if a button has a large label. For example, in a bar with 'Add...', 'Remove', 'Properties...' you may declare the properties button to use narrow margins.
Example:
The following example builds a button bar with Help button on the
left-hand side and OK, Cancel, Apply buttons on the right-hand side.
private JPanel createHelpOKCancelApplyBar( JButton help, JButton ok, JButton cancel, JButton apply) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGridded(help); builder.addRelatedGap(); builder.addGlue(); builder.addGriddedButtons(new JButton[]{ok, cancel, apply}); return builder.getPanel(); }
Constructor Summary | |
---|---|
ButtonBarBuilder()
Constructs an instance of ButtonBarBuilder on a
JPanel . |
|
ButtonBarBuilder(javax.swing.JPanel panel)
Constructs an instance of ButtonBarBuilder on the given
panel. |
Method Summary | |
---|---|
void |
addFixed(javax.swing.JComponent component)
Adds a fixed size component. |
void |
addFixedNarrow(javax.swing.JComponent component)
Adds a fixed size component with narrow margins. |
void |
addGlue()
Adds a glue that will be given the extra space, if this box is larger than its preferred size. |
void |
addGridded(javax.swing.JComponent component)
Adds a gridded component. |
void |
addGriddedButtons(javax.swing.JButton[] buttons)
Adds a sequence of related gridded buttons separated by a default gap. |
void |
addGriddedGrowing(javax.swing.JComponent component)
Adds a gridded component that grows. |
void |
addGriddedGrowingButtons(javax.swing.JButton[] buttons)
Adds a sequence of gridded buttons that grow. |
void |
addGriddedGrowingNarrow(javax.swing.JComponent component)
Adds a gridded, narrow component that grows. |
void |
addGriddedNarrow(javax.swing.JComponent component)
Deprecated. #addGridded(JComponent) already makes the border narrow |
void |
addGriddedNarrowButtons(javax.swing.JButton[] buttons)
Deprecated. #addGriddedButtons already makes the borders narrow |
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. |
void |
setDefaultButtonBarGapBorder()
Sets a default border that has a gap in the bar's north. |
Methods inherited from class com.jgoodies.forms.builder.PanelBuilder |
---|
add, addLabel, addLabel, addLabel, addLabel, addSeparator, addSeparator, addSeparator, addSeparator, addTitle, addTitle, addTitle, getPanel, setBorder, setDefaultDialogBorder |
Methods inherited from class com.jgoodies.forms.builder.AbstractFormBuilder |
---|
add, add, add, appendColumn, appendColumn, appendGlueColumn, appendGlueRow, appendRelatedComponentsGapColumn, appendRelatedComponentsGapRow, appendRow, appendRow, appendUnrelatedComponentsGapColumn, appendUnrelatedComponentsGapRow, getColumn, getColumnCount, getContainer, getLayout, getRow, getRowCount, isLeftToRight, nextColumn, nextColumn, nextLine, nextLine, nextRow, nextRow, setAlignment, setBounds, setColumn, setColumnSpan, setExtent, setHAlignment, setLeftToRight, setOrigin, setRow, setRowSpan, setVAlignment |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ButtonBarBuilder(javax.swing.JPanel panel)
ButtonBarBuilder
on the given
panel.
panel
- the layout containerpublic ButtonBarBuilder()
ButtonBarBuilder
on a
JPanel
.
Method Detail |
---|
public void setDefaultButtonBarGapBorder()
public void addGriddedButtons(javax.swing.JButton[] buttons)
buttons
- an array of buttons to addpublic void addGriddedNarrowButtons(javax.swing.JButton[] buttons)
buttons
- an array of buttons to addpublic void addGriddedGrowingButtons(javax.swing.JButton[] buttons)
buttons
- an array of buttons to addpublic void addFixed(javax.swing.JComponent component)
component
- the component to addpublic void addFixedNarrow(javax.swing.JComponent component)
component
- the component to addpublic void addGridded(javax.swing.JComponent component)
component
- the component to addpublic void addGriddedNarrow(javax.swing.JComponent component)
component
- the component to addpublic void addGriddedGrowing(javax.swing.JComponent component)
component
- the component to addpublic void addGriddedGrowingNarrow(javax.swing.JComponent component)
component
- the component to addpublic void addGlue()
public void addRelatedGap()
public void addUnrelatedGap()
public void addStrut(ConstantSize size)
size
- a ConstantSize
that describes the gap's size
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |