| | |
Bug in editable JComboBox?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
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 |
android api applet application array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) chat class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse editor error errors event eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads time tree unlimited utility webservices windows





