Horus Doc || Java GUI Reference || Doxygen's quick Index  

BarMenu Class Reference

Representation of an (extended) menu bar. More...

List of all members.

Public Methods

 BarMenu (String[] heads, String[][] commands)
 Construct BarMenu based on the heads and associated commands. More...

void addSaMethodMenu ()
 Add the default SaMethodMenu to the bar. More...

void addSaMethodMenu (String saClassName)
 Add the SaMethodMenu with the given name. More...

void addSaMethodMenu (String saClassName, String prefixKey)
 Add the SaMethodMenu with the given name and prefixKey. More...

void setEnabled (boolean b, String command)
 Enable/disable the given menu item. More...

void addBarMenuListener (BarMenuListener l)
 Add a BarMenu event listener. More...

void removeBarMenuListener (BarMenuListener l)
 Remove the given BarMenu event listener. More...

void actionPerformed (ActionEvent event)
 Implementation of ActionListener. More...


Static Public Attributes

final String DELIM = "_--_"
 A menu separator. More...

final String HELP = "Help"
 The help menu. More...


Detailed Description

Representation of an (extended) menu bar.

It needs an array of heads that will serve as names for the pulldown menus of the menu bar. For each head an array of commands is also expected. Submenus with string addressable functions based on the information in the registry can be added using addSaMethodMenu. Upon menu selections by the user this menu bar sends BarMenuEvents to the associated BarMenuListeners.


Constructor & Destructor Documentation

BarMenu::BarMenu String    heads[],
String    commands[][]
[inline]
 

Construct BarMenu based on the heads and associated commands.

Do not use "::" in commands!

00043     {
00044         doInit(heads, commands);
00045     }


Member Function Documentation

void BarMenu::addSaMethodMenu   [inline]
 

Add the default SaMethodMenu to the bar.

00077     {
00078         JMenu saMM = new SaMethodMenu(this);
00079         add(saMM);
00080     }

void BarMenu::addSaMethodMenu String    saClassName [inline]
 

Add the SaMethodMenu with the given name.

00086     {
00087         JMenu saMM = new SaMethodMenu(saClassName, this);
00088         add(saMM);
00089     }

void BarMenu::addSaMethodMenu String    saClassName,
String    prefixKey
[inline]
 

Add the SaMethodMenu with the given name and prefixKey.

00095     {
00096         JMenu saMM = new SaMethodMenu(saClassName, prefixKey, this);
00097         add(saMM);
00098     }

void BarMenu::setEnabled boolean    b,
String    command
[inline]
 

Enable/disable the given menu item.

To do: only works for part of menu given via constructor.

00105     {
00106         for (int i=0; i<heads.length; i++) {
00107             for (int j=0; j < commands[i].length; j++) {
00108                 if (commands[i][j] == command) {
00109                     JMenuItem mi = getMenu(i).getItem(j);
00110                     mi.setEnabled(b);
00111                 }
00112             }
00113         }
00114     }

void BarMenu::addBarMenuListener BarMenuListener    l [inline]
 

Add a BarMenu event listener.

00120     {
00121         listeners.addElement(l);
00122     }

void BarMenu::removeBarMenuListener BarMenuListener    l [inline]
 

Remove the given BarMenu event listener.

00128     {
00129         listeners.removeElement(l);
00130     }

void BarMenu::actionPerformed ActionEvent    event [inline]
 

Implementation of ActionListener.

Checks whether the event came from an SaMethodMenu or a normal menu By looking for "::" in the action command. Sends a BarMenuEvent to the listeners.

00139     {
00140         Vector list;
00141         String command = event.getActionCommand();
00142         int i = command.indexOf("::");
00143         int type;
00144         String menuName;
00145         if (i == -1) {
00146             type = BarMenuEvent.NORM_TYPE;
00147             int j = command.indexOf(',');
00148             menuName = command.substring(0, j);
00149             command = command.substring(j+1);
00150         } else {
00151             type = BarMenuEvent.SAMETHOD_TYPE;
00152             menuName = command.substring(0, i);
00153         }
00154 
00155         BarMenuEvent bme = new BarMenuEvent(this, command, type, menuName);
00156 
00157         synchronized (this) {
00158             list = (Vector)listeners.clone();
00159         }
00160 
00161         for (i = 0; i < list.size(); i++) {
00162             ((BarMenuListener)list.elementAt(i)).barMenuItemSelected(bme);
00163         }
00164     }


Member Data Documentation

final String BarMenu::DELIM = "_--_" [static]
 

A menu separator.

final String BarMenu::HELP = "Help" [static]
 

The help menu.


The documentation for this class was generated from the following file:
Generated on Mon Jan 27 15:11:13 2003 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001