Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

weird thing happening with JComboBox  RSS feed

alex earnshaw
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a JComboBox as an editor in a JTable, and am having a problem with the ItemListener. I have the combo set up so that the user has to double click on the cell before the combo will open (using setClickCountToStart method on DefaultCellEditor).
According to the swing tutorial, a JComboBox will fire two itemStateChanged events when a new item is selected in a combo and it will not fire any itemStateChanged events if the same item is selected.
In my combo, when you double click, the combo opens showing the drop down list, when you click again (without moving the mouse) it closes. The selection in the combo is the same as it was before you double clicked. But still the itemStateChanged event is being fired!!!
Can anyone tell me why this happens and/or how to fix it? I only want to do something when the selection actually changes....
Here is a code extract:

Thanks in advance!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!