Vinay K
Vinay K

Reputation: 473

Auto Complete JCombobox

How to have auto complete JCombobox so, that it should suggest an item which have typed word or phrase in it anywhere in the string not just starting with that string. I'm using eclipse juno IDE and solution should be JDK 1.5 supported

Upvotes: 1

Views: 293

Answers (1)

Ashwinee K Jha
Ashwinee K Jha

Reputation: 9307

You can implement your own KeySelectionManager which will be invoked when any key is typed. Default behavior is to select entry that starts with given character but you can modify it to get the current text from the text field component in the jcombo box and then select the matching entry.

You will need to look at following method in detail:

javax.swing.JComboBox.setKeySelectionManager(KeySelectionManager)

Upvotes: 1

Related Questions