super("JMenuShortcuts: " + s);
mb = new JMenuBar();
setJMenuBar(mb); // Frame implements JMenuContainer
Container cp = getContentPane();
JMenuItem mi;
// The File JMenu...
fm = new JMenu("File");
fm.setMnemonic('F");
fm.add(mi = new JMenuItem("Open", 'O"));
mi.addActionListener(this);
fm.add(mi = new JMenuItem("Close", 'W"));
mi.addActionListener(this);
fm.addSeparator();
fm.add(mi = new JMenuItem("Print", 'P"));
mi.setAccelerator(KeyStroke.getKeyStroke(
KeyEvent.VK_R, Event.ALT_MASK));
mi.addActionListener(this);
fm.addSeparator();
fm.add(mi = new JMenuItem("Exit", 'Q"));
exitItem = mi; // save for action handler
mi.addActionListener(this);
mb.add(fm);
// The Options JMenu...
om = new JMenu("Options");
om.add(new JMenuItem("Alpha"));
om.add(new JMenuItem("Gamma"));
om.add(new JMenuItem("Delta"));
mb.add(om);
// The Help JMenu...
hm = new JMenu("Help");
hm.add(mi = new JMenuItem("About"));
mi.addActionListener(this);
hm.add(mi = new JMenuItem("Topics"));
mi.addActionListener(this);
mb.add(hm);
// mb.setHelpMenu(hm); // needed for portability (Motif, etc.).
// the main window
cp.add(new MyLabel("Menu Demo Window", 200, 150));
pack();