I'm looking to make a single method that takes in my object and spits out a checkbox with an item listener.
Here's my relevant portion, the IDE wants me to make my argument and checkbox final prevents the listener from functioning during runtime.
Any ideas or help would be appreciated, thank you!
public JCheckBox makeCheckBox(Jobs object) {
JCheckBox newCheckBox = new JCheckBox(object.getName());
newCheckBox.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent e){
if(e.getSource()==this){
if(newCheckBox.isSelected()){
object.applyCost();
System.out.println("apply");
} else {
object.revokeCost();
System.out.println("revoke");
}
}
}
});
return newCheckBox;
}//JCheckBox