Section 22.4 Using Menus with Frames

• Menus neatly organize commands in a GUI. In Swing GUIs, menus can be attached only to objects of classes with method setJMenuBar (p. 917).

• A JMenuBar (p. 917) is a container for menus. A JMenuItem appears in a menu. A JMenu (p. 917) contains menu items and can be added to a JMenuBar or to other JMenus as submenus.

• When a menu is clicked, it expands to show its list of menu items.

• When a JCheckBoxMenuItem (p. 918) is selected, a check appears to the left of the menu item. When the JCheckBoxMenuItem is selected again, the check is removed.

• In a ButtonGroup, only one JRadioButtonMenuItem (p. 918) can be selected at a time.

AbstractButton method setMnemonic (p. 923) specifies the mnemonic (p. 918 ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.