com.jgoodies.uif.builder
Class ToolBarBuilder

java.lang.Object
  extended by com.jgoodies.uif.builder.ToolBarBuilder

public class ToolBarBuilder
extends Object

A builder that reduces the effort required to build, configure and fill a JToolBar with buttons and gaps. Provides several convenience methods that implicitly create buttons specialized for toolbars or implicitly configure buttons to automatically handle typical platforms differences.

Subclasses can override the default toolbar configuration in #configureToolBar and can override the creation methods #add*.

Version:
$Revision: 1.6 $
Author:
Karsten Lentzsch
See Also:
Action, ToggleAction, ToolBarButton, ToolBarToggleButton, MenuBuilder

Constructor Summary
ToolBarBuilder()
          Constructs a tool bar builder for a tool bar without name.
ToolBarBuilder(JToolBar toolBar)
          Constructs a tool bar builder for the given tool bar.
ToolBarBuilder(String name)
          Constructs a tool bar builder for a tool bar with the given name.
ToolBarBuilder(String name, Object headerStyleOrName)
          Constructs a tool bar builder for tool bar with the given name and header style.
 
Method Summary
 JButton add(Action action)
          Creates, adds and returns a ToolBarButton that is configured using the given Action.
 Component add(Component component)
          Adds a component to this builder's tool bar and returns the component.
 void add(PopupButton button)
          Adds a popup button to this builder's tool bar.
 void addGap()
          Adds a gap to the tool bar.
 void addGap(int size)
          Adds a gap to the tool bar.
 void addGlue()
          Adds a glue component to this builder's tool bar.
 void addLargeGap()
          Adds a large gap to the tool bar.
 void addSeparator()
          Adds a separator to this builder's tool bar.
 JToggleButton addToggle(ToggleAction toggleAction)
          Creates, adds and returns a ToolBarToggleButton that is configured using the given ToggleAction.
protected  void configureToolBar()
          Sets default settings for the tool bar's rollover and floatable properties: rollover and non-floatable.
static Mode getBorderPaintedDefaultMode()
          Returns the border painted default mode that is used to initialize the borderPaintedMode property.
 Mode getBorderPaintedMode()
          Returns this builder's border painted mode that is used to set the border painted mode in implicitly created tool bar buttons.
 JToolBar getToolBar()
          Returns the tool bar that is built by this builder.
static Mode getWideMarginDefaultMode()
          Returns the wide margin default mode that is used to initialize the wideMarginMode property.
 Mode getWideMarginMode()
          Returns this builder's wide margin mode that is used to set the wide margin mode in implicitly created tool bar buttons.
static void setBorderPaintedDefaultMode(Mode newDefaultMode)
          Sets a new border painted default mode that is used to initialize the borderPaintedMode property.
 void setBorderPaintedMode(Mode newMode)
          Sets a new border painted mode that is used to set the border painted mode in implicitly created tool bar buttons.
 void setBorderStyle(Object borderStyleOrName)
          Sets the JGoodies Looks border style as object or by name.
 void setHeaderStyle(Object headerStyleOrName)
          Sets the JGoodies Looks header style as object or by name.
static void setWideMarginDefaultMode(Mode newDefaultMode)
          Sets a new wide margin default mode that is used to initialize the wideMarginMode property.
 void setWideMarginMode(Mode newMode)
          Sets a new wide margin mode that is used to set the border painted mode in implicitly created tool bar buttons.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ToolBarBuilder

public ToolBarBuilder()
Constructs a tool bar builder for a tool bar without name. The tool bar has the rollover property set and is not floatable.


ToolBarBuilder

public ToolBarBuilder(String name)
Constructs a tool bar builder for a tool bar with the given name. The tool bar has the rollover property set and is not floatable.

Parameters:
name - the name for the built tool bar

ToolBarBuilder

public ToolBarBuilder(String name,
                      Object headerStyleOrName)
Constructs a tool bar builder for tool bar with the given name and header style. The tool bar has the rollover property set and is not floatable.

Parameters:
name - the name for the built tool bar
headerStyleOrName - the style applied to the built tool bar

ToolBarBuilder

public ToolBarBuilder(JToolBar toolBar)
Constructs a tool bar builder for the given tool bar. The toolbar won't be configured using #configureToolBar.

Parameters:
toolBar - the toolbar used to build
Method Detail

getBorderPaintedDefaultMode

public static Mode getBorderPaintedDefaultMode()
Returns the border painted default mode that is used to initialize the borderPaintedMode property.

Returns:
the border painted default mode

setBorderPaintedDefaultMode

public static void setBorderPaintedDefaultMode(Mode newDefaultMode)
Sets a new border painted default mode that is used to initialize the borderPaintedMode property.

Parameters:
newDefaultMode - the border painted default mode to be set

getWideMarginDefaultMode

public static Mode getWideMarginDefaultMode()
Returns the wide margin default mode that is used to initialize the wideMarginMode property.

Returns:
the wide margin default mode

setWideMarginDefaultMode

public static void setWideMarginDefaultMode(Mode newDefaultMode)
Sets a new wide margin default mode that is used to initialize the wideMarginMode property.

Parameters:
newDefaultMode - the wide margin default mode to be set

getBorderPaintedMode

public final Mode getBorderPaintedMode()
Returns this builder's border painted mode that is used to set the border painted mode in implicitly created tool bar buttons.

Returns:
the current border painted mode

setBorderPaintedMode

public final void setBorderPaintedMode(Mode newMode)
Sets a new border painted mode that is used to set the border painted mode in implicitly created tool bar buttons.

Parameters:
newMode - the border painted mode to be set

getWideMarginMode

public final Mode getWideMarginMode()
Returns this builder's wide margin mode that is used to set the wide margin mode in implicitly created tool bar buttons.

Returns:
the current wide margin mode

setWideMarginMode

public final void setWideMarginMode(Mode newMode)
Sets a new wide margin mode that is used to set the border painted mode in implicitly created tool bar buttons.

Parameters:
newMode - the wide margin mode to be set

getToolBar

public final JToolBar getToolBar()
Returns the tool bar that is built by this builder.

Returns:
this builder's tool bar

configureToolBar

protected void configureToolBar()
Sets default settings for the tool bar's rollover and floatable properties: rollover and non-floatable.

Subclasses may override to implement a different default configuration.


setBorderStyle

public final void setBorderStyle(Object borderStyleOrName)
Sets the JGoodies Looks border style as object or by name.

Parameters:
borderStyleOrName - a com.jgoodies.looks.BorderStyle or its name

setHeaderStyle

public final void setHeaderStyle(Object headerStyleOrName)
Sets the JGoodies Looks header style as object or by name.

Parameters:
headerStyleOrName - a com.jgoodies.looks.HeaderStyle or its name

addGap

public void addGap()
Adds a gap to the tool bar.


addLargeGap

public void addLargeGap()
Adds a large gap to the tool bar. Useful to separate sections.


addGap

public void addGap(int size)
Adds a gap to the tool bar.

Parameters:
size - the gap size in pixel

addGlue

public void addGlue()
Adds a glue component to this builder's tool bar. The glue is a gap that grows if the tool bar grows.


addSeparator

public void addSeparator()
Adds a separator to this builder's tool bar.


add

public void add(PopupButton button)
Adds a popup button to this builder's tool bar. Let the popup button add itself to this tool bar, because it may consists of multiple parts

Parameters:
button - the popup button to be added

add

public Component add(Component component)
Adds a component to this builder's tool bar and returns the component.

Parameters:
component - the component to be added
Returns:
the component

add

public JButton add(Action action)
Creates, adds and returns a ToolBarButton that is configured using the given Action.

Parameters:
action - an action that describes a button
Returns:
the added ToolBarButton
Throws:
IllegalArgumentException - if the action is an instance of ToggleAction

addToggle

public JToggleButton addToggle(ToggleAction toggleAction)
Creates, adds and returns a ToolBarToggleButton that is configured using the given ToggleAction.

Parameters:
toggleAction - an action that describes a toggle and provides a model
Returns:
the added ToolBarToggleButton


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.