The Menu Classes

The AWT contains four main classes to handle menus:

To use menus in your application you need to add instances of all three classes, one MenuBar with one or more Menus, each with several MenuItems.

The java.awt.MenuComponent class is the ultimate superclass of all these classes. MenuComponent extends java.lang.Object. Thus menus, menu bars, and menu items are not components and cannot be added to containers in the usual fashion.

java.lang.Object
   |
   +---java.awt.MenuComponent
           |
           +---java.awt.MenuBar
           |
           +---java.awt.MenuItem
                     |
                     +---java.awt.Menu
                               |
                               +---java.awt.PopupMenu
Both MenuBar and MenuItem extend MenuComponent. Menu extends MenuItem. (This sounds a little strange, but if you think about it a menu is an item in a menu bar.) Furthermore, MenuBar implements the java.awt.MenuContainer interface.


Previous | Next | Top
Last Modified August 15, 1997
Copyright 1997 Elliotte Rusty Harold
elharo@metalab.unc.edu