Java Reference
In-Depth Information
blueMenuItem.addActionListener(changer);
whiteMenuItem.addActionListener(changer);
//Add one menu item to the “File” menu.
JMenuItem exit = new JMenuItem(“Exit”);
fileMenu.add(exit);
exit.addActionListener(changer);
//Add one menu item and one menu to the “Help” menu.
JMenuItem about = new JMenuItem(“About MenuDemo...”);
helpMenu.add(about);
JMenu cascade = new JMenu(“Tip of the day”);
helpMenu.add(cascade);
JCheckBoxMenuItem show = new JCheckBoxMenuItem(“Show”);
cascade.add(show);
}
public static void main(String [] args)
{
MenuDemo f = new MenuDemo(“MenuDemo”);
f.setSize(300,300);
f.setVisible(true);
}
}
Figure 13.14
Output of the MenuDemo program.
Search WWH ::




Custom Search