Class ButtonStackBuilder


  • public final class ButtonStackBuilder
    extends AbstractButtonPanelBuilder
    Builds consistent button stacks that comply with popular style guides. Utilizes the JGoodies FormLayout and honors the platform's LayoutStyle regarding button sizes, and gaps.

    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) {
         return ButtonStackBuilder().create()
                    .addGridded(close)
                    .addUnrelatedGap()
                    .addGridded(up)
                    .addRelatedGap()
                    .addGridded(down)
                    .build();
     }
     
    Version:
    $Revision: 1.15 $
    See Also:
    ButtonBarBuilder, LayoutStyle