O'Reilly logo

Graphic Java™ 1.2, Volume I: AWT, Third Edition by David M. Geary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

java.awt.Checkbox

A checkbox is a component that represents a boolean state. We've already seen checkboxes in action in our LabelTest applet shown in “LabelTest Applet”.

Checkboxes fire item events whenever they are checked or unchecked. In order to react to a checkbox being checked or unchecked, an item listener is added to the checkbox. When the checkbox fires an item event, the item listener's itemStateChanged method is invoked and passed an instance of ItemEvent.

Since checkboxes often exist in mutually exclusive groups, they can be added to a java.awt.CheckboxGroup, which ensures that only one checkbox in the group is checked at any given time. Note that a CheckboxGroup is not a component and therefore cannot be added to a container. As ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required