Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class MenuBar

Constructors , Methods

public  class  java.awt.MenuBar
    extends  java.awt.MenuComponent  
    implements java.awt.MenuContainer  
{
        // Constructors
    public MenuBar();	

        // Methods
    public Menu add(Menu  m);	
    public void addNotify();	
    public int countMenus();	
    public Menu getHelpMenu();	
    public Menu getMenu(int  i);	
    public void remove(int  index);	
    public void remove(MenuComponent  m);	
    public void removeNotify();	
    public void setHelpMenu(Menu  m);	
}

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 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.

Return Value:

Returns the menu added.

ParameterDescription
m the menu to be added


addNotify

public void addNotify() 

This method calls the createMenuBar method of this object's toolkit in order to create a MenuBarPeer 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() 

Return Value:

Returns the number of menus on this menu bar.


getHelpMenu

public Menu getHelpMenu() 

Return Value:

Returns the help menu on this menu bar.


getMenu

public Menu getMenu(int  i) 

Return Value:

Returns the menu at the specified index of this menu bar.

ParameterDescription
i the position of the menu to be returned


remove

public void remove(int  index) 

Removes the menu located at the specified index from this menu bar.

ParameterDescription
index the position of the menu to be removed


remove

public void remove(MenuComponent  m) 

Removes the specified menu component from this menu bar.

ParameterDescription
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 .


setHelpMenu

public void setHelpMenu(Menu  m) 

Sets the help menu on this menu bar to be the specified menu.

ParameterDescription
m the help menu



Top© 1996 Sun Microsystems, Inc. All rights reserved.