I tried to combine a ListComboBox with AutoCompletion because I needed the resizing feature of the list itself. I extended the AutoCompletionDemo class with the following code, but when I run the demo, I get the error below.
- Code: Select all
private JPanel createPanel1() {
...
ListComboBox listComboBox = new ListComboBox(_fontNames);
ListComboBoxSearchable searchable = new ListComboBoxSearchable(listComboBox);
JTextComponent textComponent = (JTextComponent)(listComboBox.getEditor().getEditorComponent());
AutoCompletion ac = new AutoCompletion(textComponent, searchable);
Here is the error:
- Code: Select all
Exception in thread "main" java.lang.NullPointerException
at com.jidesoft.combobox.ListComboBoxSearchable.getSelectedIndex(Unknown Source)
at com.jidesoft.swing.Searchable.findFromCursor(Unknown Source)
at com.jidesoft.swing.AutoCompletion$AutoCompletionDocument.insertString(Unknown Source)
at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:655)
at javax.swing.text.JTextComponent.setText(JTextComponent.java:1693)
at com.jidesoft.swing.AutoCompletion.configureEditor(Unknown Source)
at com.jidesoft.swing.AutoCompletion.installListeners(Unknown Source)
at com.jidesoft.swing.AutoCompletion.<init>(Unknown Source)
at AutoCompletionDemo.createPanel1(AutoCompletionDemo.java:97)
at AutoCompletionDemo.getDemoPanel(AutoCompletionDemo.java:55)
at AbstractDemo.showAsFrame(AbstractDemo.java:56)
at AutoCompletionDemo.main(AutoCompletionDemo.java:171)
When I leave out the last line, the normal ListComboBox is shown so I think there is no error because of an empty combobox or so.
Can you tell me, what's wrong? Or is it generally not possible to combine those features?
Greetings, Ronny