import java.awt.Choice;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Label;
import java.awt.List;
import java.awt.Menu;
import java.awt.MenuBar;
import java.awt.MenuItem;
import java.awt.Panel;
/**
   A class that creates a frame with three menus.
*/
public class Menus extends Frame
{
  /**
     Constructor.  Builds the menus and attaches them to the
     frame.  This constructor builds the entire visible GUI.
     <p>Constructors can call other methods to help them do
     the construction job.  For example, each menu could
     have been constructed by a helper method.
     @param title the title of the frame that contains the
     menus.
  */
  public Menus(String title)
  {
    super(title);
    Font f18 = new Font("SansSerif", Font.PLAIN, 18);
    Font f14 = new Font("SansSerif", Font.PLAIN, 14);
    // The "File" menu.  This menu appears to the far left
    // of the menu bar. This menu contains three menu items.
    //
    Menu file = new Menu("File");
    file.setFont(f14);
    // Create the three menu items for the "File" menu.
    //
    MenuItem open = new MenuItem("Open...");
    open.setFont(f14);
    MenuItem openOW = new MenuItem("Open in other window...");
    openOW.setFont(f14);
    MenuItem openOF = new MenuItem("Open in other frame...");
    openOF.setFont(f14);
    // Add the three menu items to the menu.
    //
    file.add(open);
    file.add(openOW);
    file.add(openOF);
    // The "Edit" menu.  This menu appears immediately to
    // the right of the "File" menu.
    //
    Menu edit = new Menu("Edit");
    edit.setFont(f14);
    // Create the menu items for the "Edit" menu.
    //
    MenuItem undo = new MenuItem("Undo");
    undo.setFont(f14);
    MenuItem cut = new MenuItem("Cut");
    cut.setFont(f14);
    MenuItem copy = new MenuItem("Copy");
    copy.setFont(f14);
    MenuItem paste = new MenuItem("Paste");
    paste.setFont(f14);
    // Add the "Edit" menu items to the menu.
    //
    edit.add(undo);
    edit.add(cut);
    edit.add(copy);
    edit.add(paste);
    // The "Help" menu.
    //
    Menu help = new Menu("Help");
    help.setFont(f14);
    MenuItem about = new MenuItem("About...");
    about.setFont(f14);
    // Create the menu items for the "Help" menu.  Notice
    // that the "Help" menu's menu items are themselves
    // menus.
    //
    Menu basics = new Menu("Basics");
    basics.setFont(f14);
    // Create the menu items for the "Basics" submenu of the
    // "Help" menu.
    //
    MenuItem b1 = new MenuItem("Tutorial");
    b1.setFont(f14);
    MenuItem b2 = new MenuItem("News");
    b2.setFont(f14);
    MenuItem b3 = new MenuItem("Packages");
    b3.setFont(f14);
    MenuItem b4 = new MenuItem("Splash");
    b4.setFont(f14);
    // Add the menu items to the "Basics" submenu.
    //
    basics.add(b1);
    basics.add(b2);
    basics.add(b3);
    basics.add(b4);
    MenuItem faq = new MenuItem("FAQ");
    faq.setFont(f14);
    MenuItem sample = new MenuItem("Sample");
    sample.setFont(f14);
    help.add(about);
    help.add(basics);
    // The following method call adds a textured horizontal
    // line between the last menu item added to the menu,
    // and the next item that will be added.
    //
    help.addSeparator();
    // Add the remaining two menu items.  These come after
    // the separator added previously.
    //
    help.add(faq);
    help.add(sample);
    MenuBar mb = new MenuBar();
    mb.add(file);
    mb.add(edit);
    // The "Help" menu is added to the menu bar as "the help
    // menu". The "help" menu always appears to the far
    // right of the menu bar.
    //
    mb.setHelpMenu(help);
    setMenuBar(mb);
  }
  /**
     Returns the preferred size of this frame.  Because the
     frame doesn't contain any children, the inherited
     version of getPreferredSize() would be called by the
     layout manager if this method is not defined here. This
     method dictates the preferred size for the frame.
     @return the preferred size of this frame as a Dimension
     object.
  */
  public Dimension getPreferredSize()
  {
    return new Dimension(250, 250);
  }
  public static void main(String [] args)
  {
    Menus app = new Menus("Menus");
    app.pack();
    app.setVisible(true);
  }
}
public class Menus extends Frame
{
  public Menus(String title)
  {
    super(title);
    Menu file = new Menu("File");
    MenuItem open = new MenuItem("Open...");
    MenuItem openOW = new MenuItem("Open in other window...");
    MenuItem openOF = new MenuItem("Open in other frame...");
    file.add(open);
    file.add(openOW);
    file.add(openOF);
    Menu edit = new Menu("Edit");
    MenuItem undo = new MenuItem("Undo");
    MenuItem cut = new MenuItem("Cut");
    MenuItem copy = new MenuItem("Copy");
    MenuItem paste = new MenuItem("Paste");
    edit.add(undo);
    edit.add(cut);
    edit.add(copy);
    edit.add(paste);
    Menu help = new Menu("Help");
    MenuItem about = new MenuItem("About...");
    Menu basics = new Menu("Basics");
    MenuItem b1 = new MenuItem("Tutorial");
    MenuItem b2 = new MenuItem("News");
    MenuItem b3 = new MenuItem("Packages");
    MenuItem b4 = new MenuItem("Splash");
    basics.add(b1);
    basics.add(b2);
    basics.add(b3);
    basics.add(b4);
    MenuItem faq = new MenuItem("FAQ");
    MenuItem sample = new MenuItem("Sample");
    help.add(about);
    help.add(basics);
    help.addSeparator();
    help.add(faq);
    help.add(sample);
    MenuBar mb = new MenuBar();
    mb.add(file);
    mb.add(edit);
    mb.setHelpMenu(help);
    setMenuBar(mb);
  }
  public static void main(String [] args)
  {
    Menus app = new Menus("Menus");
    app.pack();
    app.setVisible(true);
  }
}