O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Cascading Menus

As previously alluded to, cascading menus are possible with the AWT by virtue of the fact that Menu extends MenuItem. As we have seen, Menu.add(MenuItem) adds a menu item to a menu. Since a Menu is a MenuItem, the Menu.add(MenuItem) method is perfectly happy to take a Menu as an argument, which it dutifully adds to itself.

Figure 17-6 shows the cascading menu created by Example 17-9.

Figure 17-6. A Cascading Menu

Example 17-9. CascadingTest Class Listing
 import java.awt.*; import java.awt.event.*; public class CascadingTest extends ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required