I need to update the items of JCombobox from the database during runtime. I had made the JCombobox editable and what i need to do is type something in the editable combobox and search the database and only display the items matching the text. For example there are if i type "ap" in the editbox of JCombobox then i want only the items containing "ap" like "apes" and "apple" i can have them in the console during runtime but when i try to set those item as an items of Jcombobox i am getting error something including "MUtation....". how can i do this . Thanx in advance
47pirates
9
Junior Poster in Training
Recommended Answers
Jump to PostWhy don't you post the entire error message? And some code? You generally do it like this:
cmb.removeAllItems(); cmb.addItem("item 1"); cmb.addItem("item 2"); ...
If there's a change of having duplicate strings, create a class and override the
toString()
method, or use anonymous classes, like:
Jump to Postcan you show the code where that exception is thrown?
Jump to PostThe problem seems to be that the document is locked when the listener is called, so when you try to update the document you can't get the lock to write to it. The solution, if you want to keep it working the same way, is to use SwingUtilities.invokeLater to run …
Jump to PostLook at all the places where you try to change the contents and replace the remove or add statements with an invokeLater that runs the remove or add later.
Jump to PostBy updating the document you are triggering your listener - which updates the document - ...
One way to avoid this is to have a shared boolean that you set when you do a programmatic update (ie in the invokeLater's run) then test this in the document listener to decide …
All 17 Replies
nmaillet
97
Posting Whiz in Training
47pirates
9
Junior Poster in Training
47pirates
9
Junior Poster in Training
stultuske
1,116
Posting Maven
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
nmaillet
97
Posting Whiz in Training
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
47pirates
9
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.