FileDocCategorySizeDatePackage
MenuTest.javaAPI DocExample2003Mon Mar 24 01:58:20 GMT 1997None

MenuTest

public class MenuTest extends Frame

Fields Summary
Constructors Summary
MenuTest()

        super ("MenuTest");
        MenuItem mi;
        Menu file = new Menu ("File", true);
        file.add ("Open");
        file.add (mi = new MenuItem ("Close"));
        mi.disable();
        Menu extras = new Menu ("Extras", false);
        extras.add (new CheckboxMenuItem ("What"));
        mi = extras.add (new MenuItem ("Yo"));
        mi = extras.add (new MenuItem ("Yo"));
        file.add (extras);
        file.addSeparator();
        file.add ("Quit");
        Menu help = new Menu("Help");
        help.add ("About");
        MenuBar mb = new MenuBar();
        mb.add (help);
        mb.add (file);
        mb.setHelpMenu (help);
        setMenuBar (mb);
        resize (200, 200);
    
Methods Summary
public booleanaction(java.awt.Event e, java.lang.Object o)

        if (e.target instanceof MenuItem) {
            if ("Quit".equals (o)) {
                dispose();
                System.exit(1);
            } else {
                System.out.println ("User selected " + o);
                if (e.target instanceof CheckboxMenuItem) {
                    CheckboxMenuItem cb = (CheckboxMenuItem)e.target;
                    System.out.println ("The value is: " + cb.getState());
                }
            }
            return true;
        }
        return false;
    
public booleanhandleEvent(java.awt.Event e)

        if (e.id == Event.WINDOW_DESTROY) {
            System.exit(0);
        }
        return super.handleEvent (e);
    
public static voidmain(java.lang.String[] args)

        MenuTest f = new MenuTest ();
        f.show();