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.

public class JCheckBox extends JToggleButton implements Accessible

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

Flash Soon


Java JCheckBox Example with ItemListener

Flash Soon


Java JCheckBox Example: Food Order

Flash Soon


Copyright ©2017 Design& develop