com.jgoodies.forms.builder
Class ButtonStackBuilder

java.lang.Object
  extended by com.jgoodies.forms.builder.AbstractBuilder
      extended by com.jgoodies.forms.builder.AbstractFormBuilder
          extended by com.jgoodies.forms.builder.PanelBuilder
              extended by com.jgoodies.forms.builder.ButtonStackBuilder

public final class ButtonStackBuilder
extends PanelBuilder

A non-visual builder that assists you in building consistent button stacks using the 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();
 }
 

Version:
$Revision: 1.15 $
Author:
Karsten Lentzsch
See Also:
ButtonBarBuilder2, ButtonBarFactory, LayoutStyle

Field Summary
 
Fields inherited from class com.jgoodies.forms.builder.AbstractBuilder
currentCellConstraints
 
Constructor Summary
ButtonStackBuilder()
          Constructs a ButtonStackBuilder on a default JPanel using a preconfigured FormLayout as layout manager.
ButtonStackBuilder(FormLayout layout, javax.swing.JPanel panel)
          Constructs a ButtonStackBuilder on the given panel and layout.
ButtonStackBuilder(javax.swing.JPanel panel)
          Constructs a ButtonStackBuilder on the given panel using a preconfigured FormLayout as layout manager.
 
Method Summary
 void 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.
 void addButton(javax.swing.JButton... buttons)
          Adds a sequence of related buttons separated by a default gap.
 void addButtons(javax.swing.JButton[] buttons)
          Adds a sequence of related buttons separated by a default gap.
 void addFixed(javax.swing.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(javax.swing.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.
 
Methods inherited from class com.jgoodies.forms.builder.PanelBuilder
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, setOpaque
 
Methods inherited from class com.jgoodies.forms.builder.AbstractFormBuilder
add, 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, setVAlignment
 
Methods inherited from class com.jgoodies.forms.builder.AbstractBuilder
createComponentFactory, getColumnCount, getComponentFactory, getContainer, getDefaultComponentFactory, getLayout, getRowCount, setComponentFactory, setDefaultComponentFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ButtonStackBuilder

public ButtonStackBuilder()
Constructs a ButtonStackBuilder on a default JPanel using a preconfigured FormLayout as layout manager.


ButtonStackBuilder

public ButtonStackBuilder(javax.swing.JPanel panel)
Constructs a ButtonStackBuilder on the given panel using a preconfigured FormLayout as layout manager.

Parameters:
panel - the layout container

ButtonStackBuilder

public ButtonStackBuilder(FormLayout layout,
                          javax.swing.JPanel panel)
Constructs a ButtonStackBuilder on the given panel and layout. The layout must have at least one column.

Parameters:
layout - the FormLayout used to layout
panel - the layout container
Since:
1.2
Method Detail

addButtons

public void addButtons(javax.swing.JButton[] buttons)
Adds a sequence of related buttons separated by a default gap.

Parameters:
buttons - an array of buttons to add

addFixed

public void addFixed(javax.swing.JComponent component)
Adds a fixed size component.

Parameters:
component - the component to add

addGridded

public void addGridded(javax.swing.JComponent component)
Adds a gridded component.

Parameters:
component - the component to add

addGlue

public void addGlue()
Adds a glue that will be given the extra space, if this box is larger than its preferred size.


addRelatedGap

public void addRelatedGap()
Adds the standard gap for related components.


addUnrelatedGap

public void addUnrelatedGap()
Adds the standard gap for unrelated components.


addStrut

public void addStrut(ConstantSize size)
Adds a strut of a specified size.

Parameters:
size - a constant that describes the gap

addButton

public void addButton(javax.swing.JButton... buttons)
Adds a sequence of related buttons separated by a default gap.

Parameters:
buttons - the array of buttons to add
Since:
1.3.0

addButton

public void 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


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