You are on page 1of 1

Assume

JCheckBox cb; String boolean text; state;

// A checkbox. // Label on text box. // True/false state of checkbox.


Creates check box, initially unchecked. Creates check box, checked or not depending on state. Returns true if the check box is checked. Checks (true) or unchecks check box. Adds an action listener to the radio button. The action listener will be called if button is selected. Add an item listener to a radio button. The item listener will be called if the button is selected or deselected.

Constructors cb = new JCheckBox(text); cb = new JCheckBox(text, state); Methods state cb.isSelected(); = cb.setSelected(state); cb.addActionListener(actionlistener); cb.addItemListener(itemlistener);

You might also like