Skip to main content

Autocomplete

3 replies [Last post]
ondreia
Offline
Joined: 2006-09-12
Points: 0

Hi to everybody
I'm using autocomplete in a jCombobox and my question is: is there a way to limit the list that appears, only to the values that belong to my search?
Example
my list has:
andrea, albert, renton, sylvia,ziggy.

So, when i insert the first letter a, it shows only andrea, albert.

It is possible???
Thanks a lot!!!

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Jesse Wilson

Hey Ondreia ---

The SwingX autocomplete stuff doesn't do filtering.
However, you can find a filtering autocomplete for Swing in
the Glazed Lists project:
http://tinyurl.com/zfdva [publicobject.com/.../AutoCompleteSupport.html]
jar: http://tinyurl.com/gtery [glazedlists_java15.jar]

A code sample:
EventList names = new BasicEventList();
names.add("andrea");
names.add("albert");
names.add("renton");
names.add("sylvia");
names.add("ziggy");
JComboBox combo = new JComboBox();
AutoCompleteSupport namesAutoComplete =
AutoCompleteSupport.install(combo, names);

Caveats to this solution:
1. I'm a biased Glazed Lists developer.
2. Although SwingX will autocomplete a JTextField, Glazed Lists
supports JComboBox only.

Cheers,
Jesse

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

ondreia
Offline
Joined: 2006-09-12
Points: 0

Thanks a lot!!!
It worked really nice!!!:))

jplemieux
Offline
Joined: 2004-11-05
Points: 0

Ondreia,

Glazed List's AutoComplete Support handles filtering the ComboBoxModel data as you type. You can watch an ~20 minute screencast that will describe how to use the API and its capabilities. The screen cast, titled "AutoCompleteSupport Screencast", is located here:

http://www.publicobject.com/glazedlistsdeveloper/

James Lemieux