Section 12.10 Buttons That Maintain State

• There are three Swing state button types—JToggleButton (p. 498), JCheckBox (p. 498) and JRadioButton (p. 498).

• Classes JCheckBox and JRadioButton are subclasses of JToggleButton.

Component method setFont (p. 500) sets the component’s font to a new Font object (p. 500) of package java.awt.

• Clicking a JCheckBox causes an ItemEvent (p. 501) that can be handled by an ItemListener (p. 501) which defines method itemStateChanged (p. 501). Method addItemListener registers the listener for the ItemEvent of a JCheckBox or JRadioButton object.

JCheckBox method isSelected determines whether a JCheckBox is selected.

JRadioButtons have two states—selected and not selected. Radio buttons (p. 495) normally ...

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.