acm.program
Class ProgramMenuBar

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JMenuBar
                          |
                          +--acm.program.ProgramMenuBar

public class ProgramMenuBar extends JMenuBar

This class standardizes the menu bars used in the ACM program package.


   
Constructor Summary
ProgramMenuBar()
Creates a ProgramMenuBar with no menus.
 
Method Summary
void addEditMenu()
Installs the Edit menu.
void addEditMenuItems(JMenu menu)
Adds the standard Edit items to the specified menu.
void addFileMenu()
Installs the File menu.
void addFileMenuItems(JMenu menu)
Adds the standard File items to the specified menu.
MenuBar createOldStyleMenuBar()
Creates a MenuBar that has the same effect as the specified JMenuBar.
JMenuItem createStandardMenuItem(String action)
Creates one of the standard menu items implemented by the ProgramMenuBar.
IOConsole getConsole()
Returns the console associated with this menu bar.
Program getProgram()
Returns the program associated with this menu bar.
void init()
Initializes the menu bar.
void setConsole(IOConsole console)
Sets the console associated with the menu bar.
void setEnabled(String action, boolean flag)
Enables or disables the menu item that generates the specified action command.
 

Constructor Detail

public ProgramMenuBar()

Creates a ProgramMenuBar with no menus.

 
Usage: ProgramMenuBar mbar = new ProgramMenuBar(); 
 
Method Detail

public void addEditMenu()

Installs the Edit menu.

 
Usage: mbar.addEditMenu(); 
 

public void addEditMenuItems(JMenu menu)

Adds the standard Edit items to the specified menu. Subclasses can override this method to change the list of items.

 
Usage: mbar.addEditMenuItems(menu); 
Parameter: 
menu  The menu to which the Edit items are added
 

public void addFileMenu()

Installs the File menu.

 
Usage: mbar.addFileMenu(); 
 

public void addFileMenuItems(JMenu menu)

Adds the standard File items to the specified menu. Subclasses can override this method to change the list of items.

 
Usage: mbar.addFileMenuItems(menu); 
Parameter: 
menu  The menu to which the File items are added
 

public MenuBar createOldStyleMenuBar()

Creates a MenuBar that has the same effect as the specified JMenuBar.

 
Usage: MenuBar oldMenuBar = mbar.createOldStyleMenuBar(); 
Returns: A MenuBar whose actions are paired with the original
 

public JMenuItem createStandardMenuItem(String action)

Creates one of the standard menu items implemented by the ProgramMenuBar. The menu item is identified by its action command, which must be one of the following: Copy, Cut, Paste, Print, Print Console, Quit, Save, Save As, Script, Select All.

 
Usage: JMenuItem item = mbar.addStandardItem(action); 
Parameter: 
action  The action command identifying the menu to be added
 

public IOConsole getConsole()

Returns the console associated with this menu bar.

 
Usage: IOConsole console = mbar.getConsole(); 
Returns: The IOConsole object currently associated with the menu bar
 

public Program getProgram()

Returns the program associated with this menu bar.

 
Usage: Program program = mbar.getProgram(); 
Returns: The Program object that controls this menu bar
 

public void init()

Initializes the menu bar. Subclasses that wish to change the composition of the menu bar beyond the default File and Edit menus should override this method with one that adds the desired menus.

 
Usage: init(); 
 

public void setConsole(IOConsole console)

Sets the console associated with the menu bar. Each console calls this method whenever it acquires the keyboard focus, which allows the menu bar to work with multiple consoles.

 
Usage: mbar.setConsole(console); 
Parameter: 
console  The IOConsole object to be used with the menu bar
 

public void setEnabled(String action, boolean flag)

Enables or disables the menu item that generates the specified action command.

 
Usage: mbar.setEnabled(action, flag); 
Parameters: 
action  The action command triggered by the menu item
flag  true to enable the item, false to disable it