【问题标题】:Wrong argument to the function - AutoComplete in JComboBox函数的参数错误 - JComboBox 中的自动完成
【发布时间】:2015-01-29 04:30:39
【问题描述】:

我正在使用 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)

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

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

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

【问题讨论】:

  • 请向我们展示整个堆栈跟踪。
  • 就是代码。您已经获得了堆栈跟踪的一部分,我们只需要查看其余部分(顶部?)。
  • 好吧,这里漏掉了一些东西......我添加了顶行
  • 你在导入什么?
  • 我要求在您的班级顶部查看您的导入语句。如果您只是发布MCVE,这会容易得多。

标签: java swing autocomplete jcombobox


【解决方案1】:

我已经导入了正确的 jar;当我检查这个问题here时,我确认了这一点。

不,它没有。这个问题仍然没有答案,因为 OP 无法解决他们的问题(请参阅该帖子上的 cmets)。此外,据我所知,SwingX 库中没有名为 Configurator 的类,您可以使用该类在组合框中获取自动完成装饰。即使在this list(您已在问题中链接)也没有这样的课程:

现在,提供自动完成装饰的正确方法是使用AutoCompleteDecorator,如下所示:

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

注意

还要注意当前版本是 1.6.4 而不是 1.6.2

【讨论】:

  • 我在这里看到了 http:link....可能是因为它旧了,但我怀疑。
  • 那个链接是针对SwingX的0.8.0 ... 当前版本是1.6.4 你还在怀疑是不是类正确? @乔万里奇
  • 是的,它是我使用的版本.....不是对正确课程的怀疑,而是因为我看到它后没有这样的课程——让我试试上面的代码跨度>
  • 但是你看到这样的类存在吗?
猜你喜欢
  • 2012-11-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多