// The "MyMenu" class. // Your Name import java.applet.*; import java.awt.*; import java.awt.event.*; public class MyMenu extends Applet { Frame f = new Frame("to hold the menu");// every menu needs to be part of a frame public void init () { Menu sub = new Menu("submenu");//create a submenu sub.add("demoitem");//put in an item sub.add(new CheckboxMenuItem("demo",true) );//put in a checkbox item Menu m = new Menu("onbar", true);// create a menu to go on a menu bar MenuItem item1 = new MenuItem("first");//put an item in the menu item1.setShortcut( new MenuShortcut(KeyEvent.VK_N));//create a shortcut using a control key m.add(item1);//put item1 in the menu //item1.addActionListener( m.addSeparator();//put in a separator MenuItem item2 = new MenuItem("second");//create another item to put in the menu item2.setEnabled(false);//disable the second item m.add(item2);//put in the disabled item m.add(sub);//put in the submenu m.add("more");//add one more item to m MenuBar mb = new MenuBar();//create a menu bar mb.add(m);//put m on the menu bar f.setMenuBar(mb);//put the menu bar into the frame f.setBounds(40, 130, 250, 130);//set the bounds on the frame size f.show();//show the frame with the menubar in it } // init method public boolean action(Event e, Object o) { if (e.target instanceof Button) //check to see if a button was pushed //see Chapter 7 for getting doubles. { } return true; }//action method public void paint (Graphics g) { // Place the body of the drawing method here } // paint method } // MyMenu class