Getting and Setting the State of a JCheckbox Component
// To create a checkbox, see Creating a JCheckbox Component
// Get the current state of the checkbox
boolean b = checkbox.isSelected();
// Set the state of the checkbox to off
checkbox.setSelected(false);
// Set the state of the checkbox to on
checkbox.setSelected(true);
Post a comment