Packages  This Package  Prev  Next  Index  

§1.30 Class MenuBar

public  class  java.awt.MenuBar
    extends  java.awt.MenuComponent  (II-§1.31)
    implements java.awt.MenuContainer  (II-§1.44)
{
        // Constructors
    public MenuBar();	§1.30.1

        // Methods
    public Menu add(Menu  m);	§1.30.2
    public void addNotify();	§1.30.3
    public int countMenus();	§1.30.4
    public Menu getHelpMenu();	§1.30.5
    public Menu getMenu(int  i);	§1.30.6
    public void remove(int  index);	§1.30.7
    public void remove(MenuComponent  m);	§1.30.8
    public void removeNotify();	§1.30.9
    public void setHelpMenu(Menu  m);	§1.30.10
}
This class that encapsulates the platform's concept of a menu bar bound to a Frame.

In order to attach the menu bar to a frame, the setMenuBar method (II-§1.19.28) in class Frame must be called.

This is what a menubar looks like


Constructors

MenuBar

public MenuBar()
Creates a new menu bar.

Methods

add

public Menu add(Menu m)
Adds the specified menu to this menu bar.
Parameters:
m - the menu to be added
Returns:
the menu added.

addNotify

public void addNotify()
This method calls the createMenuBar method (II-§1.41.15) of this object's toolkit (II-§1.10.20) in order to create a MenuBarPeer (II-§3.13) for this menu bar. This peer allows the application to change the look of a menu barwithout changing its functionality.


Most applications do not call this method directly.

countMenus

public int countMenus()
Returns:
the number of menus on this menu bar.

getHelpMenu

public Menu getHelpMenu()
Returns:
the help menu on this menu bar.

getMenu

public Menu getMenu(int i)
Parameters:
i - the position of the menu to be returned
Returns:
the menu at the specified index of this menu bar.

remove

public void remove(int index)
Removes the menu located at the specified index from this menu bar.
Parameters:
index - the position of the menu to be removed

remove

public void remove(MenuComponent m)
Removes the specified menu component from this menu bar.
Parameters:
m - the menu component to be removed

removeNotify

public void removeNotify()
Notifies this menu bar to destroy its peer.
This menu bar also notifies each of its menus to destroy their peers.
Overrides:
removeNotify in class MenuComponent (II-§1.31.7).

setHelpMenu

public void setHelpMenu(Menu m)
Sets the help menu on this menu bar to be the specified menu.
Parameters:
m - the help menu

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com