I have a checkbox on a JFrame. When I check it, I want to display on the command window that it has been selected. Below is the code i am working with. It compiles and executes without errors, but I don't get the "one has been selected" on the window when I select the checkbox.
public Checklist() {
...
JCheckBox one = new JCheckBox("CT scan performed");
one.addItemListener(new CheckBoxListener());
}
private class CheckBoxListener implements ItemListener{
public void itemStateChanged(ItemEvent e)
{
if(e.getSource()==one){ if(one.isSelected()){
System.out.println("one has been selected");
}
else{System.out.println("nothing");}
}
}}