AutoCompletion ListComboBox

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

AutoCompletion ListComboBox

Postby haer » Tue Nov 13, 2007 2:40 pm

Hello,

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
haer
 
Posts: 14
Joined: Mon Oct 01, 2007 5:07 am

Postby JIDE Support » Tue Nov 13, 2007 5:13 pm

The fix is to use
Code: Select all
        AutoCompletion ac = new AutoCompletion(textComponent, _fontNames);


ListComboBoxSearchable shouldn't be used with AutoCompletion. Searchable is for non-editable combobox. AutoCompletion is for editable combobox. So they can't be used together. The NPE is because ListComboBoxSearchable will try to get the JList on the drop down panel but failed to create it as the UI is not finalized on the screen yet. I will add code to fix this but my fix above is the correct way to do this feature.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Postby JIDE Support » Fri Nov 16, 2007 3:54 am

Just so you know, we fixed this in 2.2.1.03 patch.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 13 guests

cron