我正在使用JComboBox作为我的一个JTbale列的单元格编辑器。我想在我的JComboBox中实现自动完成。我使用了此链接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$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)
我进口了正确的罐子;当我查看这个问题here时,我确认了这一点。我添加所需功能的代码是:
combo=new JComboBox(myList);
Configurator.enableAutoCompletion(myComboBox); //this is the line generating the error.
我们如何解决这个问题?
我怀疑这一行JComboBox comboBox = [...];
它做了什么?我是以错误的方式创建我的组合框。
答案 0 :(得分:3)
&#34; 我进口了正确的罐子;当我查看这个问题here时,我确认了这一点。&#34;
不,它没有。这个问题仍然没有答案,因为OP无法解决他们的问题(见该帖子的评论)。除此之外据我所知,SwingX库中没有名为Configurator
的类,您可以使用它来在组合框中进行自动完成装饰。即使在this list(您在问题中已经链接),也没有这样的课程:
现在,提供自动完成装饰的正确方法是使用AutoCompleteDecorator
,如下所示:
JComboBox comboBox = new JComboBox();
AutoCompleteDecorator.decorate(comboBox);
另请注意,当前版本为1.6.4而不是1.6.2