Swing (javax.swing)

Creating a Checkbox Button


    JCheckBox checkBox = new JCheckBox("Label");
    checkBox.addActionListener(actionListener);
    
    // Set the current state of the checkbox.
    checkBox.setSelected(false);
    
    // Get the current state of the checkbox.
    boolean on = checkBox.isSelected();