Listing of FrameMenu1.java
// Menu1.java
// A program
that creates a menu
// Matt Smith,
Sep 1999
import
java.applet.Applet;
import
java.awt.*;
// This in an
APPLICATION that extends Frame
public class
FrameMenu1 extends Frame
{
public
FrameMenu1()
{
// set up frame window title and size
super("a frame with a menu
bar");
setSize( 300, 200 );
setVisible( true );
// set up menus
Menu fileMenu = new
Menu("File");
MenuItem newMenuItem = new MenuItem
("New");
MenuItem openMenuItem = new MenuItem
("Open");
MenuItem saveMenuItem = new MenuItem
("Save");
MenuItem exitMenuItem = new MenuItem
("Exit");
MenuItem separator?= new MenuItem ("-");
fileMenu.add(newMenuItem);
fileMenu.add(separator);
fileMenu.add(openMenuItem);
fileMenu.add(separator);
fileMenu.add(exitMenuItem);
Menu helpMenu = new
Menu("Help");
MenuItem aboutMenuItem = new MenuItem
("About");
helpMenu.add(aboutMenuItem);
// add menus to menu bar
MenuBar menuBar = new MenuBar();
menuBar.add(fileMenu);
menuBar.add(helpMenu);
// make the frame use the menubar
setMenuBar( menuBar );
}
public static
void main( String args[] )
{
// create an instance of our application
class "FrameMenu1"
FrameMenu1 app = new FrameMenu1();
}
} // class
|