函数参数错误 - JComboBox 中的自动完成

Wrong argument to the function - AutoComplete in JComboBox

我正在使用 JComboBox 作为我的一个 JTbale 的单元格编辑器 column.I 想在我的 JComboBox 中实现自动完成。我使用了这个 link here 中的一个 jar 文件。当我 运行 我的程序时,它给我这个错误:

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[=10=](MainWindow.java:90)
at quotationInterface.MainWindow$$Lambda/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.access0(EventQueue.java:97)
at java.awt.EventQueue.run(EventQueue.java:697)
at java.awt.EventQueue.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain.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)

我导入了正确的jar;当我检查这个问题 here 时,我确认了这一点。我添加所需功能的代码是:

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

我们如何解决这个问题? 我怀疑这条线 JComboBox comboBox = [...]; 它有什么作用?可能是我创建组合框的方式不对。

"我导入了正确的 jar;我在检查这个问题时确认了这一点 here"

不,不是。这个问题仍然没有答案,因为 OP 无法解决他们的问题(请参阅关于 post 的评论)。据我所知,SwingX library which you are using to get the auto-complete decoration in your combo box. Even in this list 中没有 class 命名为 Configurator(您已在问题中链接)没有这样的 class:

现在,提供 auto-complete 装饰的正确方法是使用 AutoCompleteDecorator,如下所示:

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

备注

另请注意,当前版本是 1.6.4 而不是 1.6.2