Using JCheckBoxMenuItem
I want to add some actions to the check box menu item, but I don't know how should it be done, or how the code will look like, I tried implementing ItemSelectable but it doesn't work, so should I add an action for each item of what.
Here the items are created
if(i == 0 || i == 4)
allAgents[i] =new JCheckBoxMenuItem("System Image Agent "+(i==0?1:2));
.
.
and here the action method
publicvoid itemStateChanged(ItemEvent e)
{
Object eventSource = e.getItemSelectable();
// testing
System.out.println("Method entered");
for(int i=0;i<8;i++)
{
if(eventSource == allAgents[i])
{
//testing
System.out.println("Agent "+i);
//allAgentsStatus[i] = 0;
if(allAgents[i].isSelected())
allAgentsStatus[i] = 1;
else
{
allAgentsStatus[i] = 0;
//testing
System.out.println("Agent "+i+" is not selected");
}
}
}
}

