com.jgoodies.forms.builder
Class AbstractButtonPanelBuilder

java.lang.Object
  extended by com.jgoodies.forms.builder.AbstractBuilder
      extended by com.jgoodies.forms.builder.AbstractButtonPanelBuilder
Direct Known Subclasses:
ButtonBarBuilder, ButtonBarBuilder2, ButtonStackBuilder

public abstract class AbstractButtonPanelBuilder
extends AbstractBuilder

The abstract superclass for 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.

Since:
1.2
Version:
$Revision: 1.11 $
Author:
Karsten Lentzsch

Field Summary
protected  boolean focusGrouped
          Indicates whether a focus group has been built in build().
 
Fields inherited from class com.jgoodies.forms.builder.AbstractBuilder
currentCellConstraints
 
Constructor Summary
protected AbstractButtonPanelBuilder(FormLayout layout, JPanel container)
          Constructs an AbstractButtonPanelBuilder for the given FormLayout and layout container.
 
Method Summary
protected  Component add(Component component)
          Adds a component to the container using the default cell constraints.
protected  AbstractButtonPanelBuilder 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.
protected  AbstractButtonPanelBuilder addButton(JComponent... buttons)
          Adds one or many sequences of related buttons.
protected abstract  AbstractButtonPanelBuilder addButton(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(Color background)
          Sets the panel's background color and makes the panel opaque.
protected  AbstractButtonPanelBuilder border(Border border)
          Sets the panel's border.
 JPanel build()
          Returns the panel used to build the form and lazily builds a focus traversal group for all contained AbstractButtons.
protected  JButton createButton(Action action)
          Creates and returns a button that is bound to the given Action.
protected  int getColumn()
           
 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).
protected  void nextRow()
          Increases the row by one; does the same as #nextRow(1).
protected  AbstractButtonPanelBuilder opaque(boolean b)
          Sets the panel's opaque state.
 void setBackground(Color background)
          Sets the panel's background color and makes the panel opaque.
 void setBorder(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.
 
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
 

Field Detail

focusGrouped

protected boolean focusGrouped
Indicates whether a focus group has been built in build(). Reset to false whenever a component is added.

Constructor Detail

AbstractButtonPanelBuilder

protected AbstractButtonPanelBuilder(FormLayout layout,
                                     JPanel container)
Constructs an AbstractButtonPanelBuilder for the given FormLayout and layout container.

Parameters:
layout - the FormLayout to use
container - the layout container
Throws:
NullPointerException - if layout or container is null
Method Detail

getPanel

public JPanel getPanel()
Returns the panel used to build the form and lazily builds a focus traversal group for all contained AbstractButtons.

Returns:
the panel used by this builder to build the form

build

public JPanel build()
Returns the panel used to build the form and lazily builds a focus traversal group for all contained AbstractButtons.

Returns:
the panel used by this builder to build the form

background

protected AbstractButtonPanelBuilder background(Color background)
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)

border

protected AbstractButtonPanelBuilder border(Border border)
Sets the panel's border.

Parameters:
border - the border to set
See Also:
JComponent.setBorder(Border)

opaque

protected AbstractButtonPanelBuilder opaque(boolean b)
Sets the panel's opaque state.

Parameters:
b - true for opaque, false for non-opaque
See Also:
JComponent.setOpaque(boolean)

setBackground

public void setBackground(Color background)
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

public void setBorder(Border border)
Sets the panel's border.

Parameters:
border - the border to set
See Also:
JComponent.setBorder(Border)

setOpaque

public void setOpaque(boolean b)
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's componentOrientation property.

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's componentOrientation property.

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).


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).


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.

See Also:
appendRelatedComponentsGapColumn(), appendUnrelatedComponentsGapColumn()

appendRelatedComponentsGapColumn

protected final void appendRelatedComponentsGapColumn()
Appends a column that is the default gap for related components.

See Also:
appendGlueColumn(), appendUnrelatedComponentsGapColumn()

appendUnrelatedComponentsGapColumn

protected final void appendUnrelatedComponentsGapColumn()
Appends a column that is the default gap for unrelated components.

See Also:
appendGlueColumn(), appendRelatedComponentsGapColumn()

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.

See Also:
appendRelatedComponentsGapRow(), appendUnrelatedComponentsGapRow()

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 Component add(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(JComponent button)

addButton

protected AbstractButtonPanelBuilder addButton(JComponent... buttons)
Adds one or many sequences of related buttons. A new sequence starts when a button is 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);
 

Parameters:
buttons - the buttons to add
Returns:
this builder
Throws:
NullPointerException - if buttons is null
IllegalArgumentException - if buttons is empty
See Also:
addButton(JComponent)

addButton

protected AbstractButtonPanelBuilder 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.

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 JButton createButton(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 JGoodies 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)).

Parameters:
action - provides bound visual properties for the button
Returns:
the created button
Since:
1.4


Copyright © 2002-2012 JGoodies Karsten Lentzsch. All Rights Reserved.