Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JComboBox autocomplete

Tags:

How do I perform auto-complete in editable JComboBox in Netbeans 7.1 like in ComboBox in VB dot net. I have a combo box with a list binding, I want to select item by typing only some first letter of the item in the list for example if a list has kitten, then it should be chosen when I type ki.

like image 979
user1872351 Avatar asked Dec 03 '12 11:12

user1872351


People also ask

What is the difference between JList and JComboBox?

A JComboBox is a component that displays a drop-down list and gives users options that we can select one and only one item at a time whereas a JList shows multiple items (rows) to the user and also gives an option to let the user select multiple items.

What gets the number of items in the JComboBox?

setModel(ComboBoxModel a) : sets the data model that the JComboBox uses to obtain the list of items. setMaximumRowCount(int count): sets the maximum number of rows the JComboBox displays.

How do I make JComboBox not editable?

u can make ur jcombobox uneditable by calling its setEnabled(false). A JComboBox is unEditable by default. You can make it editable with the setEditable(boolean) command. If you are talking about enabled or disabled you can set that by the setEnabled(boolean) method.

Which listener is implemented for JComboBox?

Adds a PopupMenu listener which will listen to notification messages from the popup portion of the combo box. Initializes the editor with the specified item. Sets the properties on this combobox to match those in the specified Action . This method is public as an implementation side effect.


Video Answer


1 Answers

If you want to do this yourself, you can follow the steps explained in this article.

this.comboBox = new JComboBox(new Object[] { "Ester", "Jordi",         "Jordina", "Jorge", "Sergi" }); AutoCompleteDecorator.decorate(this.comboBox); 
like image 198
Robin Avatar answered Oct 04 '22 19:10

Robin