FileDocCategorySizeDatePackage
MenuTest12.javaAPI DocExample2563Mon Mar 24 01:58:24 GMT 1997None

MenuTest12

public class MenuTest12 extends Frame implements ActionListener

Fields Summary
Constructors Summary
public MenuTest12()

        super ("MenuTest");
        MenuItem mi;
        Menu file = new Menu ("File", true);
        file.add (new MyMenuItem ("Open", this));
        mi = file.add (new MyMenuItem ("Close", this));
        mi.setEnabled(false);
        Menu extras = new Menu ("Extras", false);
        mi = extras.add (new CheckboxMenuItem ("What"));
        mi.addActionListener(this);
        mi = extras.add (new MyMenuItem ("Yo", this));
        mi.setActionCommand ("Yo1");
        mi = extras.add (new MyMenuItem ("Yo", this));
        mi.setActionCommand ("Yo2");
        file.add (extras);
        file.addSeparator();
        file.add (new MyMenuItem ("Quit", this));
        Menu help = new Menu("Help");
        help.add (new MyMenuItem ("About", this));
        MenuBar mb = new MenuBar();
        mb.add (help);
        mb.add (file);
        mb.setHelpMenu (help);
        setMenuBar (mb);
        setSize (200, 200);
        enableEvents (AWTEvent.WINDOW_EVENT_MASK);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        if (e.getActionCommand().equals("Quit")) {
            System.exit(0);
        }
        System.out.println ("User selected " + e.getActionCommand());
        if (e.getSource() instanceof ItemSelectable) {
            ItemSelectable is = (ItemSelectable)e.getSource();
            System.out.println ("The value is: " + (is.getSelectedObjects().length != 0));
        }
    
public static voidmain(java.lang.String[] args)

        MenuTest12 f = new MenuTest12 ();
        f.show();
    
protected voidprocessWindowEvent(java.awt.event.WindowEvent e)

        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
            super.processWindowEvent (e);
            System.exit(0);
        } else {
            super.processWindowEvent (e);
        }