I use addActionListener
for JButtons while addItemListener
is more convenient for a JToggleButton
. Together with if(event.getStateChange()==ItemEvent.SELECTED)
, in the latter case, I add Events for whenever the JToggleButton is checked/unchecked.