buoy.widget
Class BToolBar

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.WidgetContainer
              extended by buoy.widget.BToolBar

public class BToolBar
extends WidgetContainer

A BToolBar is a WidgetContainer which displays a series of Widgets in a row or column. It is similar to a RowContainer or ColumnContainer, but has a different appearance. Most often, the child Widgets are BButtons with icons, and they act as shortcuts for performing common operations.

Author:
Peter Eastman

Nested Class Summary
static class BToolBar.Orientation
          This inner class represents an orientation for the toolbar.
 
Field Summary
static BToolBar.Orientation HORIZONTAL
           
static BToolBar.Orientation VERTICAL
           
 
Constructor Summary
BToolBar()
          Create a new BToolBar whose orientation is set to HORIZONTAL.
BToolBar(BToolBar.Orientation orientation)
          Create a new BToolBar.
 
Method Summary
 void add(Widget widget)
          Add a Widget (usually a BButton) to the end of the toolbar.
 void add(Widget widget, int index)
          Add a Widget (usually a BButton) to the toolbar.
 void addSeparator()
          Add a dividing line (a BSeparator) to the end of the toolbar.
 Widget getChild(int i)
          Get the i'th child of this container.
 int getChildCount()
          Get the number of children in this container.
 int getChildIndex(Widget widget)
          Get the index of a particular Widget.
 java.util.Collection<Widget> getChildren()
          Get a Collection containing all child Widgets of this container.
 javax.swing.JToolBar getComponent()
          Get the java.awt.Component corresponding to this Widget.
 BToolBar.Orientation getOrientation()
          Get the orientation of this toolbar.
 void layoutChildren()
          Layout the child Widgets.
 void remove(Widget widget)
          Remove a child Widget from this container.
 void removeAll()
          Remove all child Widgets from this container.
 void setOrientation(BToolBar.Orientation orientation)
          Set the orientation of this toolbar.
 
Methods inherited from class buoy.widget.WidgetContainer
isOpaque, setOpaque
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final BToolBar.Orientation HORIZONTAL

VERTICAL

public static final BToolBar.Orientation VERTICAL
Constructor Detail

BToolBar

public BToolBar()
Create a new BToolBar whose orientation is set to HORIZONTAL.


BToolBar

public BToolBar(BToolBar.Orientation orientation)
Create a new BToolBar.

Parameters:
orientation - the orientation of the toolbar
Method Detail

getComponent

public javax.swing.JToolBar getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class Widget

getOrientation

public BToolBar.Orientation getOrientation()
Get the orientation of this toolbar.


setOrientation

public void setOrientation(BToolBar.Orientation orientation)
Set the orientation of this toolbar.


add

public void add(Widget widget)
Add a Widget (usually a BButton) to the end of the toolbar.

Parameters:
widget - the Widget to add

add

public void add(Widget widget,
                int index)
Add a Widget (usually a BButton) to the toolbar.

Parameters:
widget - the Widget to add
index - the position at which to add it

addSeparator

public void addSeparator()
Add a dividing line (a BSeparator) to the end of the toolbar.


getChildCount

public int getChildCount()
Get the number of children in this container.

Specified by:
getChildCount in class WidgetContainer

getChild

public Widget getChild(int i)
Get the i'th child of this container.


getChildren

public java.util.Collection<Widget> getChildren()
Get a Collection containing all child Widgets of this container.

Specified by:
getChildren in class WidgetContainer

remove

public void remove(Widget widget)
Remove a child Widget from this container.

Specified by:
remove in class WidgetContainer

removeAll

public void removeAll()
Remove all child Widgets from this container.

Specified by:
removeAll in class WidgetContainer

getChildIndex

public int getChildIndex(Widget widget)
Get the index of a particular Widget.

Parameters:
widget - the Widget to locate
Returns:
the position of the Widget within this container, or -1 if the Widget is not a child of this container

layoutChildren

public void layoutChildren()
Layout the child Widgets. This may be invoked whenever something has changed (the size of this WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be called in turn.

Specified by:
layoutChildren in class WidgetContainer


Written by Peter Eastman.