I have a combobox, with certain elements within it, eg:开发者_Go百科 "abc", "pqr", now when the user types "a", I wish to refresh the combobox and remove all its elements and then again add only those elements which start with the user string. (These elements are stored in a array)
I tried in to modify its elements in "addCaretListener" but it throws "java.lang.IllegalStateException: Attempt to mutate in notification" Exception
Is there a specific way to implement this?
Thanks
consider using two JComboBoxes or Autocompleted JTextField plus JComboBox (instead of your described request), there you have to get all highlighted Chars ( create only contructor to the same method as filtering Item(s) ) from JTextField and dynamically update ComboBoxModel
I think you create the AutoComplete combo see this example
http://snippets.dzone.com/posts/show/7633
or see this post
Filter Combobox Data in Java
http://forums.devshed.com/delphi-programming-90/how-to-filter-combobox-items-on-onchangeevent-251852.html
精彩评论