buoy.widget

Class 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.
Collection
getChildren()
Get a Collection containing all child Widgets of this container.
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

getChildCount, getChildren, isOpaque, layoutChildren, remove, removeAll, setOpaque

Methods inherited from class buoy.widget.Widget

addEventLink, dispatchEvent, getBackground, getBounds, getComponent, 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, addEventLink, dispatchEvent, removeEventLink

Field Details

HORIZONTAL

public static final BToolBar.Orientation HORIZONTAL

VERTICAL

public static final BToolBar.Orientation VERTICAL

Constructor Details

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 Details

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.

getChild

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

getChildCount

public int getChildCount()
Get the number of children in this container.
Overrides:
getChildCount in interface 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

getChildren

public Collection getChildren()
Get a Collection containing all child Widgets of this container.
Overrides:
getChildren in interface WidgetContainer

getComponent

public JToolBar getComponent()
Get the java.awt.Component corresponding to this Widget.
Overrides:
getComponent in interface Widget

getOrientation

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

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.
Overrides:
layoutChildren in interface WidgetContainer

remove

public void remove(Widget widget)
Remove a child Widget from this container.
Overrides:
remove in interface WidgetContainer

removeAll

public void removeAll()
Remove all child Widgets from this container.
Overrides:
removeAll in interface WidgetContainer

setOrientation

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

Written by Peter Eastman.