14.10 Buttons That Maintain State
The Swing GUI components contain three types of state buttons—JToggleButton
, JCheckBox
and JRadioButton
—that have on/off or true/false values. Classes JCheckBox
and JRadioButton
are subclasses of JToggleButton
(Fig. 14.14). A JRadioButton
is different from a JCheckBox
in that normally several JRadioButton
s are grouped together and are mutually exclusive—only one in the group can be selected at any time, just like the buttons on a car radio. We first discuss class JCheckBox
.
14.10.1 JCheckBox
The application of Figs. 14.17–14.18 uses two JCheckBox
es to select the desired font style of the text displayed in a JTextField
. When selected, one applies a bold style and the other an italic style. If both are selected, ...
Get Java How to Program (early objects), 9/e 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.