How can I invalidade a selection on item listener? Make a new selection inside the item listener? won't that be a infinite loop? :o
remove
ItemListener
fromJComboBox
, then callJComboBox.setSelectedIndex(-1)
, addItemListener
back toJComboBo
x (standard and good practicies)create two void (standard and good practicies) in one add listener, in second remove listener
don't wrap
if(e.getStateChange() == ItemEvent.DESELECTED)
insideboolean
for the reason, to block code executions untill reset status endeduse
if - else
forif(e.getStateChange() == ItemEvent.DESELECTED){ .... } else { ... }