I have a number of checkboxes in my Swing Project. For each checkbox select/deselect a particular query is to be executed. I know one way of getting the source of checkbox is
public void itemStateChanged(ItemEvent e) {
if(e.getSource=="checkbox object")
{
some code goes here;
}
}
If i have small number of checkboxes than this solution is best but if i have many checkboxes then i have to write lengthy code. Is there a way to find the object of checkbox that causes the event in a single command?
You can get selected checkbox by like this