This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
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
This note was uploaded on 06/16/2008 for the course CSIS 2102 taught by Professor Teneja during the Spring '07 term at Stockton.
- Spring '07