This
preview
has intentionally blurred sections.
Sign up to view the full version.
Unformatted text preview: JMenuItem fileExitItem = new JMenuItem("Exit"); fileMenu.add(fileExitItem); 2 Menu Items • Add a listener to each menu item: • Add action listeners only to menu items, not to menus or the menu bar fileExitItem.addActionListener(listener); A Sample Program • Builds up a small but typical menu • Traps action events from menu items • To keep program readable, use a separate method for each menu or set of related menus – createFaceItem : creates menu item to change the font face – createSizeItem – createStyleItem...
View
Full Document
- Spring '07
- Teneja
- Menu bar, menus
-
Click to edit the document details