Looking for a Combo(Viewer) in SWT/JFace which supports autocomplete

Aaron Digulla picture Aaron Digulla · Jul 1, 2009 · Viewed 10.9k times · Source

I'm looking for a Combo(Viewer) in SWT/JFace which supports autocomplete / type-ahead, i.e. the user can enter a couple of characters and the drop down list should show all matching elements.

Answer

thehiatus picture thehiatus · Sep 22, 2009

You can also check out the org.eclipse.jface.fieldassist.AutoCompleteField class. It's not a combo, just a text field, but it adds auto complete functionality as if it were a combo very easily. You can do something as simple as this:

Text textField = new Text(parentComposite, SWT.BORDER);
new AutoCompleteField(textField, new TextContentAdapter(), new String[] 
    {"autocomplete option 1", "autocomplete option 2"});