Search code examples
javaswingautocompletejcombobox

Wrong argument to the function - AutoComplete in JComboBox


I am using a JComboBox as a cell editor for one of my JTbale column.I want to implement autocomplete in my JComboBox. I used a jar file from this link here. When I run my program it is giving me this error:

at Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: (class: org/jdesktop/swingx/autocomplete/Configurator, method: enableAutoCompletion signature: (Ljavax/swing/JComboBox;)V) Incompatible argument to functionquotationTable.DescriptionColumnEditor.populateComboBox(DescriptionColumnEditor.java:68)
at quotationTable.DescriptionColumnEditor.<init>(DescriptionColumnEditor.java:31)
at quotationTable.Table.initComponent(Table.java:40)
at quotationTable.Table.<init>(Table.java:28)
at quotationInterface.TablePane.addTable(TablePane.java:40)
at quotationInterface.TablePane.<init>(TablePane.java:25)
at quotationInterface.QuotationTabPane.createQuotPane(QuotationTabPane.java:35)
at quotationInterface.QuotationTabPane.<init>(QuotationTabPane.java:23)
at quotationInterface.MainWindow.<init>(MainWindow.java:37)
at quotationInterface.MainWindow.lambda$main$0(MainWindow.java:90)
at quotationInterface.MainWindow$$Lambda$1/798154996.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I have imported the right jar; this I confirmed when I checked with this question here. My code for adding the functionality needed is:

 combo=new JComboBox(myList);
        Configurator.enableAutoCompletion(myComboBox); //this is the line generating the error.

How do we resolve this? I was suspecting this lineJComboBox comboBox = [...]; what does it do? It my be that I am creating my combobox the wrong way.


Solution

  • "I have imported the right jar; this I confirmed when I checked with this question here."

    No it doesn't. That question still unanswered because OP couldn't solve their problem (see the comments on that post). Besides as far as I know there is no class named Configurator in SwingX library which you are using to get the auto-complete decoration in your combo box. Even in this list (you've linked in your question) there is no such class:

    No org.jdesktop.swingx.autocomplete.Configurator class

    Now, the right way to provide auto-complete decoration is using AutoCompleteDecorator as follows:

     JComboBox comboBox = new JComboBox();
     AutoCompleteDecorator.decorate(comboBox);
    

    Note

    Also note the current version is 1.6.4 not 1.6.2