Java Utililty Methods JCheckBox

List of utility methods to do JCheckBox

Description

The list of methods to do JCheckBox are organized into topic(s).

Method

JCheckBoxaddCheckBox(Container container, String label, String placement, boolean debug)
Add a check box (with label) to parent container
JCheckBox checkBox = new JCheckBox(label);
container.add(checkBox, placement);
checkBox.setOpaque(false);
return checkBox;
StringconvertToYesNo(JCheckBox checkBox)
convert To Yes No
if (checkBox.isSelected())
    return "Yes";
return "No";
JCheckBoxcreateCheckBox(final String title, final Preferences node, final String pref_name, final boolean default_val)
create Check Box
final JCheckBox check_box = new JCheckBox(title);
check_box.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(final ActionEvent ae) {
        node.putBoolean(pref_name, check_box.isSelected());
});
check_box.setSelected(node.getBoolean(pref_name, default_val));
...
JCheckBoxcreateCheckBox(String name, String command, boolean selected)
create Check Box
return createCheckBox(null, name, command, selected);
JCheckBoxcreateCheckBox(String s, boolean b)
Builds a personalized checkbox using a smaller than usual font.
JCheckBox cb = new JCheckBox(" " + s + " ", b);
cb.setFont(new Font("serif", Font.PLAIN, 12));
cb.setHorizontalAlignment(JCheckBox.LEFT);
return cb;
JCheckBoxcreateJCheckBox(Rectangle bounds)
Creates a new JCheckBox object with the given properties.
JCheckBox jCheckBox = new JCheckBox();
jCheckBox.setBounds(bounds);
return jCheckBox;
voidexclusive(final JCheckBox first, final boolean firstState, final JCheckBox second, final boolean secondState)
Declares states for two checkboxes to be mutually exclusive.
ActionListener l = new ActionListener() {
    private void check(final JCheckBox checked, final boolean checkedState, final JCheckBox changed,
            final boolean impliedState) {
        if (checked.isSelected() == checkedState) {
            changed.setSelected(impliedState);
            changed.setEnabled(false);
        } else {
            changed.setEnabled(true);
...
voidimply(final JCheckBox checked, final boolean checkedState, final JCheckBox changed, final boolean impliedState)
Checks state of the checked checkbox and if state is checkedState than to disable changed checkbox and change its state to impliedState .
ActionListener l = new ActionListener() {
    Boolean previousState;
    public void actionPerformed(ActionEvent e) {
        if (checked.isSelected() == checkedState) {
            if (previousState == null) {
                previousState = changed.isSelected();
            changed.setEnabled(false);
...
voidinitJCheckBox(JCheckBox box, String element)
Initiates the Check Box
box.setSelected(Boolean.parseBoolean(element));
booleanisCheckBoxModified(JCheckBox checkBox, boolean originalValue)
is Check Box Modified
return checkBox.isSelected() != originalValue;