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

A File Menu

Let's start off our discussion of menus residing in menubars with a simple example that creates the file menu in Figure 17-2.

Figure 17-2. A File Menu

Most applications that provide a menubar have a file menu as the leftmost menu in their menubar, and most provide menu items similar to those we have added to our example. Implementing such a menu is straightforward, as illustrated in Example 17-1.

Example 17-1. FileMenuTest Class Listing
 import java.awt.*; import java.awt.event.*; public class FileMenuTest extends Frame { private MenuBar mbar; private MenuItem newItem, openItem, saveAsItem, saveItem, quitItem; private MenuItemListener ...

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