• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

weird thing happening with JComboBox

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
Alex
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic