Javatpoint Logo
Javatpoint Logo

Java JCheckBox

The JCheckBox class is used to create a checkbox. It is used to turn an option on (true) or off (false). Clicking on a CheckBox changes its state from "on" to "off" or from "off" to "on ".It inherits JToggleButton class.

JCheckBox class declaration

Let's see the declaration for javax.swing.JCheckBox class.

Commonly used Constructors:

Constructor Description
JJCheckBox() Creates an initially unselected check box button with no text, no icon.
JChechBox(String s) Creates an initially unselected check box with text.
JCheckBox(String text, boolean selected) Creates a check box with text and specifies whether or not it is initially selected.
JCheckBox(Action a) Creates a check box where properties are taken from the Action supplied.

Commonly used Methods:

Methods Description
AccessibleContext getAccessibleContext() It is used to get the AccessibleContext associated with this JCheckBox.
protected String paramString() It returns a string representation of this JCheckBox.

Java JCheckBox Example


JAVA Jcheckbox 1

Java JCheckBox Example with ItemListener


JAVA Jcheckbox 2

Java JCheckBox Example: Food Order


JAVA Jcheckbox 21 JAVA Jcheckbox 22
Next TopicJava JRadioButton

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA