Полезная информация

Java AWT

Previous Chapter 19
java.awt Reference
Next
 

MenuBar

Name

MenuBar

[Graphic: Figure from the text]

Description

A MenuBar holds menus. MenuBars are always attached to frames, and displayed on the top line of the Frame. One menu in a MenuBar may be designated a "help" menu.

Class Definition

public class java.awt.MenuBar
    extends java.awt.MenuComponent
    implements java.awt.MenuContainer {
  
  // Constructors
  public MenuBar();
  
  // Instance Methods
  public synchronized Menu add (Menu m);
  public void addNotify();
  public int countMenus(); (Deprecated)
  public void deleteShortcut (MenuShortcut s); (New)
  public Menu getHelpMenu();
  public Menu getMenu (int index);
  public int getMenuCount(); (New)
  public MenuItem getShortcutMenuItem (MenuShortcut s); (New)
  public synchronized void remove (int index);
  public synchronized void remove (MenuComponent component);
  public void removeNotify();
  public synchronized void setHelpMenu (Menu m);
  public synchronized Enumeration shortcuts(); (New)
}

Constructors

MenuBar

public MenuBar()

Description

Constructs a MenuBar object.

Instance Methods

add

public synchronized Menu add (Menu m)

Parameters

m

A Menu to add to MenuBar.

Returns

Item just added.

Description

Adds a new menu to the MenuBar.

addNotify

public void addNotify()

Description

Creates MenuBar's peer and peers of contained menus.

countMenus

public int countMenus() (Deprecated)

Returns

The number of menus on the menu bar. Replaced by getMenuCount().

deleteShortcut

public void deleteShortcut (MenuShortcut s) (New)

Parameters

s

The shortcut to remove.

Description

Removes a menu shortcut.

getHelpMenu

public Menu getHelpMenu()

Returns

The menu that was designated the help menu.

getMenu

public Menu getMenu (int index)

Parameters

index

The position of the Menu to fetch.

Returns

The Menu at the designated position.

getMenuCount

public int getMenuCount() (New)

Returns

The number of menus on the menu bar.

getShortcutMenuItem

public MenuItem getShortcutMenuItem (MenuShortcut s) (New)

Parameters

s

A menu shortcut.

Returns

The corresponding menu item.

Description

Finds the MenuItem corresponding to the given MenuShortcut, or null if no match is found.

remove

public synchronized void remove (int index)

Parameters

index

The position of the Menu to remove.

Description

Removes a Menu from the MenuBar.

public synchronized void remove (MenuComponent component)

Parameters

component

The element of the MenuBar to remove.

Implements

MenuContainer.remove()

Description

Removes a Menu from the MenuBar.

removeNotify

public void removeNotify()

Description

Destroys the MenuBar peer, and peers for all Menu objects that appear on it.

setHelpMenu

public synchronized void setHelpMenu (Menu m)

Parameters

m

Menu to designate as the help menu.

Description

Designates a Menu as the MenuBar's help menu.

shortcuts

public synchronized Enumeration shortcuts() (New)

Returns

An Enumeration of MenuShortcut objects.

Description

Returns an Enumeration of all MenuShortcut objects managed by this MenuBar.

See Also

Frame, Menu, MenuComponent, MenuContainer


Previous Home Next
Menu Book Index MenuComponent

Java in a Nutshell Java Language Reference Java AWT Java Fundamental Classes Exploring Java