tags:

views:

322

answers:

1

My goal is to create some kind of swing component that can do two things:

  1. Function as a combo box (select from a list of values)
  2. Allow a user to type into the component and only display the relevant items from the original list (like some AJAX search boxes online)

I would really like to do this by customizing an existing swing component so I don't have to write it from scratch, but so far I have not found anything that can do this. I have considered the massive amounts of hacks that it would take to possibly get a JComboBox to do this, but I don't really think that will work.

Any recommendations on what the best way to do this would be? Bonus points for solutions that aren't 100% custom code.

+1  A: 

What you are looking for can be found be using autocomplete in your search strings.

Comboboxes which support what you want for sure exist in several libraries just one example:

Glazed Lists

The following site contains a few samples (for glazedlists too) and further links to other libraries. It's a bit dated but I guess the information is still ok.

Adding Auto-Completion Support to Swing Comboboxes

jitter
glazed lists turned out to be very helpful. i did however have to add some custom code to make them do exactly what i wanted. i ran into the ugly beast that is java's gui thread model, and this article turned out to be very informative:http://www.javaworld.com/javaworld/jw-08-2007/jw-08-swingthreading.html
twolfe18