Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.jgoodies.forms.builder
Class ButtonBarBuilder

    java.lang.Object
      com.jgoodies.forms.builder.AbstractBuilder
          com.jgoodies.forms.builder.AbstractFormBuilder
              com.jgoodies.forms.builder.PanelBuilder
                  com.jgoodies.forms.builder.ButtonBarBuilder

Deprecated. Replaced by the `ButtonBarBuilder2` that comes with a smaller, safer, better, and more convenient API.

    @Deprecated
    public final class ButtonBarBuilder

extends PanelBuilder

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 buttons use their own size. Gridded buttons honor the default minimum button width as specified by the current `LayoutStyle`.

You can set an optional hint for narrow margin for the fixed width buttons. This is useful if you want to lay out a button bar that includes a button with a long text. For example, in a bar with 'Copy to Clipboard', 'OK', 'Cancel' you may declare the clipboard button as a fixed size button with narrow margins, OK and Cancel as gridded. Gridded buttons are marked as narrow by default. 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.

To honor the platform's button order (left-to-right vs. right-to-left) this builder uses the leftToRightButtonOrder property. It is initialized with the current LayoutStyle's button order, which in turn is left-to-right on most platforms and right-to-left on the Mac OS X. Builder methods that create sequences of buttons (e.g. `addGriddedButtons(JButton[])` honor the button order. If you want to ignore the default button order, you can either add individual buttons, or create a ButtonBarBuilder instance with the order set to left-to-right. For the latter see `createLeftToRightBuilder()`. Also see the button order example below.

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.addUnrelatedGap();
         builder.addGlue();
         builder.addGriddedButtons(new JButton[]{ok, cancel, apply});
         return builder.getPanel();
     }

Button Order Example:
The following example builds three button bars where one honors the platform's button order and the other two ignore it.

     public JComponent buildPanel() {
         FormLayout layout = new FormLayout("pref");
         DefaultFormBuilder rowBuilder = new DefaultFormBuilder(layout);
         rowBuilder.setDefaultDialogBorder();

         rowBuilder.append(buildButtonSequence(new ButtonBarBuilder()));
         rowBuilder.append(buildButtonSequence(ButtonBarBuilder.createLeftToRightBuilder()));
         rowBuilder.append(buildIndividualButtons(new ButtonBarBuilder()));

         return rowBuilder.getPanel();
     }

     private Component buildButtonSequence(ButtonBarBuilder builder) {
         builder.addGriddedButtons(new JButton[] {
                 new JButton("One"),
                 new JButton("Two"),
                 new JButton("Three")
         });
         return builder.getPanel();
     }

     private Component buildIndividualButtons(ButtonBarBuilder builder) {
         builder.addGridded(new JButton("One"));
         builder.addRelatedGap();
         builder.addGridded(new JButton("Two"));
         builder.addRelatedGap();
         builder.addGridded(new JButton("Three"));
         return builder.getPanel();
     }

Version:
  $Revision: 1.18 $
Author:
  Karsten Lentzsch
See Also:
  `ButtonStackBuilder`, `ButtonBarFactory`, `LayoutStyle`

Field Summary

Fields inherited from class com.jgoodies.forms.builder.AbstractBuilder
`currentCellConstraints`

Constructor Summary
`ButtonBarBuilder()` Deprecated. Constructs an instance of `ButtonBarBuilder` on a `JPanel` using a preconfigured FormLayout as layout manager.
`ButtonBarBuilder(JPanel panel)` Deprecated. Constructs an instance of `ButtonBarBuilder` on the given panel using a preconfigured FormLayout as layout manager.

Method Summary
`void` | `addFixed(JComponent component)` Deprecated. Adds a fixed size component.
`void` | `addFixedNarrow(JComponent component)` Deprecated. Adds a fixed size component with narrow margins.
`void` | `addGlue()` Deprecated. Adds a glue that will be given the extra space, if this box is larger than its preferred size.
`void` | `addGridded(JComponent component)` Deprecated. Adds a gridded component, i.e. a component that will get the same dimension as all other gridded components.
`void` | `addGriddedButtons(JButton[] buttons)` Deprecated. Adds a sequence of related gridded buttons each separated by a default gap.
`void` | `addGriddedGrowing(JComponent component)` Deprecated. Adds a gridded component that grows.
`void` | `addGriddedGrowingButtons(JButton[] buttons)` Deprecated. Adds a sequence of gridded buttons that grow where each is separated by a default gap.
`void` | `addRelatedGap()` Deprecated. Adds the standard horizontal gap for related components.
`void` | `addStrut(ConstantSize width)` Deprecated. Adds a horizontal strut of the specified width.
`void` | `addUnrelatedGap()` Deprecated. Adds the standard horizontal gap for unrelated components.
`static ButtonBarBuilder` | `createLeftToRightBuilder()` Deprecated. Creates and returns a `ButtonBarBuilder` with initialized with a left to right button order.
`boolean` | `isLeftToRightButtonOrder()` Deprecated. Returns whether button sequences will be ordered from left to right or from right to left.
`void` | `setDefaultButtonBarGapBorder()` Deprecated. Sets a default border that has a gap in the bar's north.
`void` | `setLeftToRightButtonOrder(boolean newButtonOrder)` Deprecated. Sets the order for button sequences to either left to right, or right to left.

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

### ButtonBarBuilder

    public ButtonBarBuilder()

  Deprecated.
  Constructs an instance of `ButtonBarBuilder` on a `JPanel` using a preconfigured FormLayout as layout manager.

### ButtonBarBuilder

    public ButtonBarBuilder(JPanel panel)

  Deprecated.
  Constructs an instance of `ButtonBarBuilder` on the given panel using a preconfigured FormLayout as layout manager.

  Parameters:
    `panel` - the layout container

Method Detail

### createLeftToRightBuilder

    public static ButtonBarBuilder createLeftToRightBuilder()

  Deprecated.
  Creates and returns a `ButtonBarBuilder` with initialized with a left to right button order.

  Returns:
    a button bar builder with button order set to left-to-right

### isLeftToRightButtonOrder

    public boolean isLeftToRightButtonOrder()

  Deprecated.
  Returns whether button sequences will be ordered from left to right or from right to left.

  Returns:
    true if button sequences are ordered from left to right
  Since:
    1.0.3
  See Also:
    `LayoutStyle.isLeftToRightButtonOrder()`

### setLeftToRightButtonOrder

    public void setLeftToRightButtonOrder(boolean newButtonOrder)

  Deprecated.
  Sets the order for button sequences to either left to right, or right to left.

  Parameters:
    `newButtonOrder` - true if button sequences shall be ordered from left to right
  Since:
    1.0.3
  See Also:
    `LayoutStyle.isLeftToRightButtonOrder()`

### setDefaultButtonBarGapBorder

    public void setDefaultButtonBarGapBorder()

  Deprecated.
  Sets a default border that has a gap in the bar's north.

### addGriddedButtons

    public void addGriddedButtons(JButton[] buttons)

  Deprecated.
  Adds a sequence of related gridded buttons each separated by a default gap. Honors this builder's button order. If you want to use a fixed left to right order, add individual buttons.

  Parameters:
    `buttons` - an array of buttons to add
  See Also:
    `LayoutStyle`

### addGriddedGrowingButtons

    public void addGriddedGrowingButtons(JButton[] buttons)

  Deprecated.
  Adds a sequence of gridded buttons that grow where each is separated by a default gap. Honors this builder's button order. If you want to use a fixed left to right order, add individual buttons.

  Parameters:
    `buttons` - an array of buttons to add
  See Also:
    `LayoutStyle`

### addFixed

    public void addFixed(JComponent component)

  Deprecated.
  Adds a fixed size component. Unlike the gridded components, this component keeps its individual preferred dimension.

  Parameters:
    `component` - the component to add

### addFixedNarrow

    public void addFixedNarrow(JComponent component)

  Deprecated.
  Adds a fixed size component with narrow margins. Unlike the gridded components, this component keeps its individual preferred dimension.

  Parameters:
    `component` - the component to add

### addGridded

    public void addGridded(JComponent component)

  Deprecated.
  Adds a gridded component, i.e. a component that will get the same dimension as all other gridded components.

  Parameters:
    `component` - the component to add

### addGriddedGrowing

    public void addGriddedGrowing(JComponent component)

  Deprecated.
  Adds a gridded component that grows. The component's initial size (before it grows) is the same as for all other gridded components.

  Parameters:
    `component` - the component to add

### addGlue

    public void addGlue()

  Deprecated.
  Adds a glue that will be given the extra space, if this box is larger than its preferred size.

### addRelatedGap

    public void addRelatedGap()

  Deprecated.
  Adds the standard horizontal gap for related components.

  See Also:
    `LayoutStyle.getRelatedComponentsPadX()`

### addUnrelatedGap

    public void addUnrelatedGap()

  Deprecated.
  Adds the standard horizontal gap for unrelated components.

  See Also:
    `LayoutStyle.getUnrelatedComponentsPadX()`

### addStrut

    public void addStrut(ConstantSize width)

  Deprecated.
  Adds a horizontal strut of the specified width. For related and unrelated components use `addRelatedGap()` and `addUnrelatedGap()` respectively.

  Parameters:
    `width` - describes the gap width
  See Also:
    `ColumnSpec.createGap(ConstantSize)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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