Package com.jgoodies.forms.internal
Class AbstractButtonPanelBuilder<B extends AbstractButtonPanelBuilder<B>>
- java.lang.Object
-
- com.jgoodies.forms.internal.AbstractBuilder<B>
-
- com.jgoodies.forms.internal.AbstractButtonPanelBuilder<B>
-
- Type Parameters:
B- the type of the builder, e.g. ButtonBarBuilder
- Direct Known Subclasses:
ButtonBarBuilder,ButtonStackBuilder
public abstract class AbstractButtonPanelBuilder<B extends AbstractButtonPanelBuilder<B>> extends AbstractBuilder<B>
The abstract superclass forButtonBarBuilderandButtonStackBuilder. 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.- Since:
- 1.2
- Version:
- $Revision: 1.11 $
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanfocusGroupedIndicates whether a focus group has been built inbuild().private booleanleftToRightSpecifies if we fill the grid from left to right or right to left.-
Fields inherited from class com.jgoodies.forms.internal.AbstractBuilder
currentCellConstraints
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractButtonPanelBuilder(FormLayout layout, javax.swing.JPanel container)Constructs an AbstractButtonPanelBuilder for the given FormLayout and layout container.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected java.awt.Componentadd(java.awt.Component component)Adds a component to the container using the default cell constraints.protected AbstractButtonPanelBuilderaddButton(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 abstract AbstractButtonPanelBuilderaddButton(javax.swing.JComponent button)protected AbstractButtonPanelBuilderaddButton(javax.swing.JComponent... buttons)Adds one or many sequences of related buttons.protected abstract AbstractButtonPanelBuilderaddRelatedGap()Adds the standard gap for related components.protected abstract AbstractButtonPanelBuilderaddUnrelatedGap()Adds the standard gap for unrelated components.protected voidappendColumn(ColumnSpec columnSpec)Appends the given column specification to the builder's layout.protected voidappendGlueColumn()Appends a glue column.protected voidappendGlueRow()Appends a glue row.protected voidappendRelatedComponentsGapColumn()Appends a column that is the default gap for related components.protected voidappendRelatedComponentsGapRow()Appends a row that is the default gap for related components.protected voidappendRow(RowSpec rowSpec)Appends the given row specification to the builder's layout.protected voidappendUnrelatedComponentsGapColumn()Appends a column that is the default gap for unrelated components.protected voidappendUnrelatedComponentsGapRow()Appends a row that is the default gap for unrelated components.javax.swing.JPanelbuild()Returns the panel used to build the form and lazily builds a focus traversal group for all contained AbstractButtons.protected javax.swing.JButtoncreateButton(javax.swing.Action action)Creates and returns a button that is bound to the given Action.protected intgetColumn()private intgetColumnIncrementSign()Returns the sign (-1 or 1) used to increment the cursor's column when moving to the next column.protected intgetRow()Returns the cursor's row.booleanisLeftToRight()Returns whether this builder fills the form left-to-right or right-to-left.protected voidnextColumn()Moves to the next column, does the same as #nextColumn(1).private voidnextColumn(int columns)Moves to the next column.protected voidnextRow()Increases the row by one; does the same as #nextRow(1).private voidnextRow(int rows)Increases the row by the specified rows.voidsetBackground(java.awt.Color background)Deprecated.Replaced byAbstractBuilder.background(Color)voidsetBorder(javax.swing.border.Border border)Deprecated.Replaced byAbstractBuilder.border(Border)voidsetLeftToRight(boolean b)Sets the form fill direction to left-to-right or right-to-left.voidsetOpaque(boolean b)Deprecated.Replaced byAbstractBuilder.opaque(boolean)-
Methods inherited from class com.jgoodies.forms.internal.AbstractBuilder
background, border, border, createComponentFactory, getColumnCount, getComponentFactory, getContainer, getLayout, getPanel, getRowCount, opaque, padding, padding, setComponentFactory
-
-
-
-
Field Detail
-
leftToRight
private boolean leftToRight
Specifies if we fill the grid from left to right or right to left. This value is initialized during the construction from the layout container's component orientation.- See Also:
isLeftToRight(),setLeftToRight(boolean),ComponentOrientation
-
focusGrouped
protected boolean focusGrouped
Indicates whether a focus group has been built inbuild(). Reset tofalsewhenever a component is added.
-
-
Constructor Detail
-
AbstractButtonPanelBuilder
protected AbstractButtonPanelBuilder(FormLayout layout, javax.swing.JPanel container)
Constructs an AbstractButtonPanelBuilder for the given FormLayout and layout container.- Parameters:
layout- the FormLayout to usecontainer- the layout container- Throws:
java.lang.NullPointerException- iflayoutorcontainerisnull
-
-
Method Detail
-
build
public final javax.swing.JPanel build()
Returns the panel used to build the form and lazily builds a focus traversal group for all contained AbstractButtons.- Specified by:
buildin classAbstractBuilder<B extends AbstractButtonPanelBuilder<B>>- Returns:
- the panel used by this builder to build the form
-
setBackground
@Deprecated public final void setBackground(java.awt.Color background)
Deprecated.Replaced byAbstractBuilder.background(Color)Sets the panel's background color and makes the panel opaque.- Parameters:
background- the color to set as new background- See Also:
JComponent.setBackground(Color)
-
setBorder
@Deprecated public final void setBorder(javax.swing.border.Border border)
Deprecated.Replaced byAbstractBuilder.border(Border)Sets the panel's border.- Parameters:
border- the border to set- See Also:
JComponent.setBorder(Border)
-
setOpaque
@Deprecated public final void setOpaque(boolean b)
Deprecated.Replaced byAbstractBuilder.opaque(boolean)Sets the panel's opaque state.- Parameters:
b- true for opaque, false for non-opaque- Since:
- 1.1
- See Also:
JComponent.setOpaque(boolean)
-
isLeftToRight
public final boolean isLeftToRight()
Returns whether this builder fills the form left-to-right or right-to-left. The initial value of this property is set during the builder construction from the layout container'scomponentOrientationproperty.- Returns:
- true indicates left-to-right, false indicates right-to-left
- See Also:
setLeftToRight(boolean),ComponentOrientation
-
setLeftToRight
public final void setLeftToRight(boolean b)
Sets the form fill direction to left-to-right or right-to-left. The initial value of this property is set during the builder construction from the layout container'scomponentOrientationproperty.- Parameters:
b- true indicates left-to-right, false right-to-left- See Also:
isLeftToRight(),ComponentOrientation
-
nextColumn
protected final void nextColumn()
Moves to the next column, does the same as #nextColumn(1).
-
nextColumn
private void nextColumn(int columns)
Moves to the next column.- Parameters:
columns- number of columns to move
-
getColumn
protected final int getColumn()
-
getRow
protected final int getRow()
Returns the cursor's row.- Returns:
- the cursor's row
-
nextRow
protected final void nextRow()
Increases the row by one; does the same as #nextRow(1).
-
nextRow
private void nextRow(int rows)
Increases the row by the specified rows.- Parameters:
rows- number of rows to move
-
appendColumn
protected final void appendColumn(ColumnSpec columnSpec)
Appends the given column specification to the builder's layout.- Parameters:
columnSpec- the column specification object to append
-
appendGlueColumn
protected final void appendGlueColumn()
Appends a glue column.
-
appendRelatedComponentsGapColumn
protected final void appendRelatedComponentsGapColumn()
Appends a column that is the default gap for related components.
-
appendUnrelatedComponentsGapColumn
protected final void appendUnrelatedComponentsGapColumn()
Appends a column that is the default gap for unrelated components.
-
appendRow
protected final void appendRow(RowSpec rowSpec)
Appends the given row specification to the builder's layout.- Parameters:
rowSpec- the row specification object to append
-
appendGlueRow
protected final void appendGlueRow()
Appends a glue row.
-
appendRelatedComponentsGapRow
protected final void appendRelatedComponentsGapRow()
Appends a row that is the default gap for related components.- See Also:
appendGlueRow(),appendUnrelatedComponentsGapRow()
-
appendUnrelatedComponentsGapRow
protected final void appendUnrelatedComponentsGapRow()
Appends a row that is the default gap for unrelated components.- See Also:
appendGlueRow(),appendRelatedComponentsGapRow()
-
add
protected final java.awt.Component add(java.awt.Component component)
Adds a component to the container using the default cell constraints. Note that when building from left to right, this method won't adjust the cell constraints if the column span is larger than 1.- Parameters:
component- the component to add- Returns:
- the added component
-
addButton
protected abstract AbstractButtonPanelBuilder addButton(javax.swing.JComponent button)
-
addButton
protected AbstractButtonPanelBuilder addButton(javax.swing.JComponent... buttons)
Adds one or many sequences of related buttons. A new sequence starts when a button isnull. The next sequence is separated by an unrelated gap. Each button has the minimum width as specified byLayoutStyle.getDefaultButtonWidth(). The gap width between the buttons isLayoutStyle.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);
- Parameters:
buttons- the buttons to add- Returns:
- this builder
- Throws:
java.lang.NullPointerException- ifbuttonsisnulljava.lang.IllegalArgumentException- ifbuttonsis empty- See Also:
addButton(JComponent)
-
addButton
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.- Parameters:
actions- an array of buttons to add
-
addRelatedGap
protected abstract AbstractButtonPanelBuilder addRelatedGap()
Adds the standard gap for related components.
-
addUnrelatedGap
protected abstract AbstractButtonPanelBuilder addUnrelatedGap()
Adds the standard gap for unrelated components.
-
createButton
protected javax.swing.JButton createButton(javax.swing.Action action)
Creates and returns a button that is bound to the given Action. This is a hook that allows to return customized buttons. For example, the JGoodiesJGButtonconfigures 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)).- Parameters:
action- provides bound visual properties for the button- Returns:
- the created button
- Since:
- 1.4
-
getColumnIncrementSign
private int getColumnIncrementSign()
Returns the sign (-1 or 1) used to increment the cursor's column when moving to the next column.- Returns:
- -1 for right-to-left, 1 for left-to-right
-
-