| | |
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 |
3d 6 @param affinetransform android api applet application arc array arrays automation binary bluetooth bold byte c++ chat class client code color compare component coordinates database detection doctype eclipse educational error file fractal froglogic game givemetehcodez graphics gui guitesting helpwithhomework html ide ideas image ingres input integer internet intersect j2me java java.xls javaexcel javaprojects jni jpanel jtextarea julia keytool keyword linux list loop map method methods mobile netbeans newbie nextline object pong print problem producer program programming project projectideas read recursion recursive replaysolutions rim scanner sell server set size sms sort sql string swing terminal threads tree web websites windows





