0

I want to make a autocomplete textbox. I have an Entity Location

@Entity
public class Location {

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int lId;
private String lName;

public Location() {
    super();
}

public Location(int lId, String lName) {
    super();
    this.lId = lId;
    this.lName = lName;
}
//getters and setters

It should be something like this

enter image description here

I have no idea how to complete this task. I have tried jQuery Autocomplite, but it wasn't success. Can anyone explaine me, how can i make it works. I have already tried this solution. But it didn't help me. It doesnt work.

  • Is this in Java or C#, because the code and tags suggests Java, but your Window1 form suggests C#? – Igoranze Jun 15 '16 at 13:45
  • Possible duplicate of [Create a autocompleting textbox in Java with a dropdown list](http://stackoverflow.com/questions/14186955/create-a-autocompleting-textbox-in-java-with-a-dropdown-list) – Igoranze Jun 15 '16 at 13:47

1 Answers1

1

If you dont want to use a third-party library then use this: example

Else if you don't mind using third-party code, then you could use this one:

GlazedList implementation auto-completion.

You can install GlazedList on a JComboBox with only one line of Glazed code, like this:

JComboBox comboBox = new JComboBox();
Object[] elements = new Object[] {"name person", "name person", "name person", "name person"};
AutoCompleteSupport.install(comboBox, GlazedLists.eventListOf(elements));

Glazed Lists: source

Community
  • 1
  • 1
Igoranze
  • 1,506
  • 13
  • 35