Download autocomplete text box / dropdown menu

We need an autocomplete component for the swing, the problem with jdesktop / SwingX is that we have to use the combo box and after each key press it just scrolls to the closest match, but the combo still contains 25,000 items, It doesn't show 4 or 5, which are the closest match, because they can be in different places on the list. We do not want to display a list with 25,000 either ...

Is there something similar to JSF autocomplete or google homepage? We need a component that gives our interface something like

public List getOptions (String typedSoFar) {// here we return 5 matching our criteria and just offers // those five to the user}

+3
source share
4 answers

A very easy way to do this is to use the AutoFill implementation of GlazedList. It is very easy to get up and work. You can find it here:

http://publicobject.com/glazedlists/

You can install autocompletion on JComboBox with only one line of glazed code, for example:

JComboBox comboBox = new JComboBox ();
Object [] elements = new Object [] {"Cat", "Dog", "Lion", "Mouse"};
AutoCompleteSupport.install (comboBox, GlazedLists.eventListOf (elements));
+5
source

GlazedList Not very good, also SwingX Auto-Complete support and simpler than "GlazedList". you only write:

AutoCompleteDecorator.decorate(yourComboBox);
+1
source

swingX - .

AutoCompleteDecorator.decorate(textComplete, strings, true);

textComplete - , strings - jList , - .

0
source

I have not used SwingX and do not know anything about their implementation. It would be best to extend the SwingX Autocomplete class. Instead of using the Autocomplete class, directly create a proprietary class, extend the Autocomplete class, and override the getOptions () method:

class OurOwnAutocomplete extending swingx.*.*.autocomplete {

    private List getOptions(String typedSoFar) { // 

    // logic 

   }
-2
source

Source: https://habr.com/ru/post/1755042/


All Articles