JCheckbox - ActionListener and ItemListener?

前端 未结 5 1818
南旧
南旧 2020-12-13 08:40

Both ActionListener and ItemListener are used to fire an event with JCheckBox?

So, what\'s the difference between them and in which case one of them is preferred to

5条回答
  •  悲哀的现实
    2020-12-13 09:01

    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.

提交回复
热议问题