public abstract class AbstractButtonPanelBuilder extends AbstractBuilder
ButtonBarBuilder.
Provides a cell cursor for traversing
the button bar/stack while components are added. It also offers
convenience methods to append logical columns and rows.TODO: Mention the ButtonStackBuilder2 subclass as soon as it is available.
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
focusGrouped
Indicates whether a focus group has been built in
build(). |
private boolean |
leftToRight
Specifies if we fill the grid from left to right or right to left.
|
currentCellConstraints| Modifier | Constructor and Description |
|---|---|
protected |
AbstractButtonPanelBuilder(FormLayout layout,
javax.swing.JPanel container)
Constructs an AbstractButtonPanelBuilder
for the given FormLayout and layout container.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.awt.Component |
add(java.awt.Component component)
Adds a component to the container using the default cell constraints.
|
protected AbstractButtonPanelBuilder |
addButton(javax.swing.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.
|
protected AbstractButtonPanelBuilder |
addButton(javax.swing.JComponent... buttons)
Adds one or many sequences of related buttons.
|
protected abstract AbstractButtonPanelBuilder |
addButton(javax.swing.JComponent button) |
protected abstract AbstractButtonPanelBuilder |
addRelatedGap()
Adds the standard gap for related components.
|
protected abstract AbstractButtonPanelBuilder |
addUnrelatedGap()
Adds the standard gap for unrelated components.
|
protected void |
appendColumn(ColumnSpec columnSpec)
Appends the given column specification to the builder's layout.
|
protected void |
appendGlueColumn()
Appends a glue column.
|
protected void |
appendGlueRow()
Appends a glue row.
|
protected void |
appendRelatedComponentsGapColumn()
Appends a column that is the default gap for related components.
|
protected void |
appendRelatedComponentsGapRow()
Appends a row that is the default gap for related components.
|
protected void |
appendRow(RowSpec rowSpec)
Appends the given row specification to the builder's layout.
|
protected void |
appendUnrelatedComponentsGapColumn()
Appends a column that is the default gap for unrelated components.
|
protected void |
appendUnrelatedComponentsGapRow()
Appends a row that is the default gap for unrelated components.
|
protected AbstractButtonPanelBuilder |
background(java.awt.Color background)
Sets the panel's background color and makes the panel opaque.
|
protected AbstractButtonPanelBuilder |
border(javax.swing.border.Border border)
Sets the panel's border.
|
javax.swing.JPanel |
build()
Returns the panel used to build the form and lazily builds
a focus traversal group for all contained AbstractButtons.
|
protected javax.swing.JButton |
createButton(javax.swing.Action action)
Creates and returns a button that is bound to the given Action.
|
protected int |
getColumn() |
private int |
getColumnIncrementSign()
Returns the sign (-1 or 1) used to increment the cursor's column
when moving to the next column.
|
javax.swing.JPanel |
getPanel()
Returns the panel used to build the form and lazily builds
a focus traversal group for all contained AbstractButtons.
|
protected int |
getRow()
Returns the cursor's row.
|
boolean |
isLeftToRight()
Returns whether this builder fills the form left-to-right
or right-to-left.
|
protected void |
nextColumn()
Moves to the next column, does the same as #nextColumn(1).
|
private void |
nextColumn(int columns)
Moves to the next column.
|
protected void |
nextRow()
Increases the row by one; does the same as #nextRow(1).
|
private void |
nextRow(int rows)
Increases the row by the specified rows.
|
protected AbstractButtonPanelBuilder |
opaque(boolean b)
Sets the panel's opaque state.
|
void |
setBackground(java.awt.Color background)
Sets the panel's background color and makes the panel opaque.
|
void |
setBorder(javax.swing.border.Border border)
Sets the panel's border.
|
void |
setLeftToRight(boolean b)
Sets the form fill direction to left-to-right or right-to-left.
|
void |
setOpaque(boolean b)
Sets the panel's opaque state.
|
createComponentFactory, getColumnCount, getComponentFactory, getContainer, getLayout, getRowCount, setComponentFactoryprivate boolean leftToRight
isLeftToRight(),
setLeftToRight(boolean),
ComponentOrientationprotected boolean focusGrouped
build().
Reset to false whenever a component is added.protected AbstractButtonPanelBuilder(FormLayout layout, javax.swing.JPanel container)
layout - the FormLayout to usecontainer - the layout containerjava.lang.NullPointerException - if layout or container is nullpublic javax.swing.JPanel getPanel()
public javax.swing.JPanel build()
protected AbstractButtonPanelBuilder background(java.awt.Color background)
background - the color to set as new backgroundJComponent.setBackground(Color)protected AbstractButtonPanelBuilder border(javax.swing.border.Border border)
border - the border to setJComponent.setBorder(Border)protected AbstractButtonPanelBuilder opaque(boolean b)
b - true for opaque, false for non-opaqueJComponent.setOpaque(boolean)public void setBackground(java.awt.Color background)
background - the color to set as new backgroundJComponent.setBackground(Color)public void setBorder(javax.swing.border.Border border)
border - the border to setJComponent.setBorder(Border)public void setOpaque(boolean b)
b - true for opaque, false for non-opaqueJComponent.setOpaque(boolean)public final boolean isLeftToRight()
componentOrientation property.setLeftToRight(boolean),
ComponentOrientationpublic final void setLeftToRight(boolean b)
componentOrientation property.b - true indicates left-to-right, false right-to-leftisLeftToRight(),
ComponentOrientationprotected final void nextColumn()
private void nextColumn(int columns)
columns - number of columns to moveprotected final int getColumn()
protected final int getRow()
protected final void nextRow()
private void nextRow(int rows)
rows - number of rows to moveprotected final void appendColumn(ColumnSpec columnSpec)
columnSpec - the column specification object to appendprotected final void appendGlueColumn()
protected final void appendRelatedComponentsGapColumn()
protected final void appendUnrelatedComponentsGapColumn()
protected final void appendRow(RowSpec rowSpec)
rowSpec - the row specification object to appendprotected final void appendGlueRow()
protected final void appendRelatedComponentsGapRow()
appendGlueRow(),
appendUnrelatedComponentsGapRow()protected final void appendUnrelatedComponentsGapRow()
appendGlueRow(),
appendRelatedComponentsGapRow()protected java.awt.Component add(java.awt.Component component)
component - the component to addprotected abstract AbstractButtonPanelBuilder addButton(javax.swing.JComponent button)
protected AbstractButtonPanelBuilder addButton(javax.swing.JComponent... buttons)
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);
buttons - the buttons to addjava.lang.NullPointerException - if buttons is nulljava.lang.IllegalArgumentException - if buttons is emptyaddButton(JComponent)protected AbstractButtonPanelBuilder addButton(javax.swing.Action... actions)
actions - an array of buttons to addprotected abstract AbstractButtonPanelBuilder addRelatedGap()
protected abstract AbstractButtonPanelBuilder addUnrelatedGap()
protected javax.swing.JButton createButton(javax.swing.Action action)
JGButton configures
the accessible name and accessible description from Actions
that provide these information.
This default implementation delegates the button creation
to this builder's component factory,
see ComponentFactory.createButton(Action)).
action - provides bound visual properties for the buttonprivate int getColumnIncrementSign()