public void itemStateChanged(ItemEvent e) { Object source = e.getItemSelectable(); if (e.getStateChange() == ItemEvent.DESELECTED) { myAgent.leaveCommunity(((JCheckBox) source).getText()); } else { myAgent.joinCommunity(((JCheckBox) source).getText()); } }
void communityChange(boolean b, String name) { if (b) myAgent.joinCommunity(name); else myAgent.leaveCommunity(name); }