This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes weird thing happening with JComboBox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "weird thing happening with JComboBox" Watch "weird thing happening with JComboBox" New topic

weird thing happening with JComboBox

alex earnshaw
Ranch Hand

Joined: Nov 05, 2001
Posts: 60
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!
Have you checked out Aspose?
subject: weird thing happening with JComboBox
It's not a secret anymore!