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
.
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.
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.
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.
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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With