Checkbox Menu Items

The AWT provides a CheckboxMenuItem class. A CheckboxMenuItem is a menu item that toggles between checked and unchecked when activated. Figure 17-5 shows a CheckboxMenuItem at work.

Figure 17-5. A Checkbox Menu Item. Activated menu items toggle between checked or unchecked.

A CheckboxMenuItem is often used in a menu that exhibits radio button behavior. That is, when one of the menu items is checked, the other items in the menu are all unchecked, so that only one checkbox menu item is checked at a time.

It is a simple matter to extend Menu and provide a RadioMenu class that adds CheckboxMenuItem items (only) and implements the ...

Get Graphic Java™ 1.2, Volume I: AWT, Third 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.