| | |
Bug in editable JComboBox?
Thread Solved |
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.
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.
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().
http://bugs.sun.com/bugdatabase/view...bug_id=6729824
I got around it by doing mycombox.getEditor().getItem() rather than mycombox.getSelectedItem().
![]() |
Other Threads in the Java Forum
- Previous Thread: Cant get this to compile any good ideas please
- Next Thread: Please help Errors will not compile
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui homework html ide if_statement image integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql sqlite stop string swing testautomation threads transforms tree ui unicode validation windows





