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 the other?
Both ItemListener as well as ActionListener, in case of JCheckBox have the same behaviour. However, major difference is ItemListener can be triggered by calling the setSelected(true) on the checkbox. As a coding practice do not register both ItemListener as well as ActionListener with the JCheckBox, in order to avoid inconsistency.
ItemListener
ActionListener
JCheckBox
setSelected(true)
1.4m articles
1.4m replys
5 comments
57.0k users