Java JCheckBoxThe 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 declarationLet'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 ExampleOutput:
Java JCheckBox Example with ItemListenerOutput:
Java JCheckBox Example: Food OrderOutput:
|