Chapter 29. Radio Buttons and Toolbars

Swing provides separate implementations of both the JRadioButton and the JCheckBox. A check box has two states, and within a group of check boxes, any number can be selected or deselected. Radio buttons should be grouped into aButtonGroup object so that only one radio button of a group can be selected at a time.

Radio Buttons

Both radio buttons and check boxes can be instantiated with an image as well as a title, and both can have rollover icons. The JCheckBox component is derived from the simpler JToggleButton object. JToggleButton is a button that can be switched between two states by clicking but which stays in that new state (up or down) like a two-state check box does. Further, the JToggle Button can take ...

Get Java™ Design Patterns: A Tutorial 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.