mardi 14 juillet 2015

Keeping Track of Every Time that a Checkbox is checked and unchecked

I have most of my java application done already, so I am now logging all user activity. One thing I want to keep track of is whenever one of my checkboxes is checked and unchecked. I am able to read at the end if the object is checked or unchecked, however I want to know each time the checkbox is used in real time. I want to know how many times the user checks and unchecks the box. Right now I am using something similar to this syntax, but it doesn't print a statement each time the checkbox is checked and unchecked.

public CheckboxAction(String text) {
    super(text);
}

@Override
public void actionPerformed(ActionEvent event) {
    JCheckBox cbLog = (JCheckBox) event.getSource();
    if (cbLog.isSelected()) {
        System.out.println("Logging is enabled");
    } else {
        System.out.println("Logging is disabled");
    }
}




Aucun commentaire:

Enregistrer un commentaire