943,801 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 1176
  • Java RSS
Aug 12th, 2008
0

Bug in editable JComboBox?

Expand Post »
Hi,

I have a swing app where I am using (among other things obviously) an editable JComboBox and a jButton.

when the JButton is clicked, it does some processing and uses the value in the JComboBox as one of it's inputs. I'm finding that everything is fine when:

- The value of the combobox is changed via the drop down
- The value of the combox is changed by typing AND the user either tabs or clicks on another field

however, if the user changes the value of the combobox by typing and then clicks on the button, the OLD value of what was in the combox is what the JButton sees when doing the getSelectedItem(). If the user clicks on the button a second time, then the new value is available via the getSelectedItem().

is this a known issue or are there any workarounds available? i was thinking that when the user clicks the button I would just 'pretend/force a focus change' as if the user had clicked on another field prior to hitting the button.

Any recommendations would be welcome.
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005
Aug 15th, 2008
0

Re: Bug in editable JComboBox?

Apparently this is a known bug in java - see link below:
http://bugs.sun.com/bugdatabase/view...bug_id=6729824

I got around it by doing mycombox.getEditor().getItem() rather than mycombox.getSelectedItem().
Reputation Points: 68
Solved Threads: 18
Posting Pro in Training
winbatch is offline Offline
466 posts
since Feb 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Cant get this to compile any good ideas please
Next Thread in Java Forum Timeline: Please help Errors will not compile





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC