buoy.widget

Class BMenu

Implemented Interfaces:
MenuWidget

public class BMenu
extends WidgetContainer
implements MenuWidget

A BMenu is a WidgetContainer corresponding to a pulldown menu in the menu bar of a window.
Author:
Peter Eastman

Constructor Summary

BMenu()
Create a new BMenu with no title.
BMenu(String title)
Create a new BMenu.

Method Summary

void
add(MenuWidget widget)
Add a MenuWidget (typically a BMenuItem or another BMenu) to the end of the menu.
void
add(MenuWidget widget, int index)
Add a MenuWidget (typically a BMenuItem or another BMenu) to the menu.
void
addSeparator()
Add a dividing line (a BSeparator) to the end of the menu.
MenuWidget
getChild(int i)
Get the i'th child of this container.
int
getChildCount()
Get the number of children in this container.
Iterator
getChildren()
Get an Iterator listing all child Widgets.
int
getMnemonic()
Get the mnemonic which can be used to activate this menu in keyboard navigation mode.
String
getText()
Get the title of this menu which appears in the menu bar.
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
setMnemonic(int key)
Set the mnemonic which can be used to activate this menu in keyboard navigation mode.
void
setText(String title)
Set the title of this menu which appears in the menu bar.

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

Constructor Details

BMenu

public BMenu()
Create a new BMenu with no title.

BMenu

public BMenu(String title)
Create a new BMenu.
Parameters:
title - the title of the menu

Method Details

add

public void add(MenuWidget widget)
Add a MenuWidget (typically a BMenuItem or another BMenu) to the end of the menu.
Parameters:
widget - the MenuWidget to add

add

public void add(MenuWidget widget,
                int index)
Add a MenuWidget (typically a BMenuItem or another BMenu) to the menu.
Parameters:
widget - the MenuWidget 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 menu.

getChild

public MenuWidget 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

getChildren

public Iterator getChildren()
Get an Iterator listing all child Widgets.
Overrides:
getChildren in interface WidgetContainer

getMnemonic

public int getMnemonic()
Get the mnemonic which can be used to activate this menu in keyboard navigation mode.
Returns:
the key code (defined by the KeyEvent class) which activates this menu

getText

public String getText()
Get the title of this menu which appears in the menu bar.

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

setMnemonic

public void setMnemonic(int key)
Set the mnemonic which can be used to activate this menu in keyboard navigation mode.
Parameters:
key - the key code (defined by the KeyEvent class) which activates this menu

setText

public void setText(String title)
Set the title of this menu which appears in the menu bar.

Written by Peter Eastman.