Java – jcombobox itemstatechanged event is called twice at a time

@H_ 419_ 2@resultCombo = new JCombo@R_611_2419 @(); resultCombo. addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent ie) { sampleText=resultCombo.getSelectedItem().toString(); System.out.println("SampleText : "+sampleText); } }); output: SampleText : selectedword SampleText : selectedword

Why is this event called twice when an item is selected in a combo box

Solution

For individual changes, JComobo@R_611_2419 @Itemlistener will be called twice One for selected events and one for deselected events

For information on how to write itemlistener, see this tutorial page

Basically all you have to do is

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>