简体   繁体   English

Java Swing GUI异常-线程“ AWT-EventQueue-0”中的异常java.util.NoSuchElementException:矢量枚举

[英]Java Swing GUI exception - Exception in thread “AWT-EventQueue-0” java.util.NoSuchElementException: Vector Enumeration

I get this exception when i run my application. 运行应用程序时出现此异常。 I dont have any idea what is going wrong here. 我不知道这是怎么回事。 Can someone help please. 有人可以帮忙吗。

Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException: Vector Enumeration at java.util.Vector$1.nextElement(Vector.java:305) at javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:778) at javax.swing.JComponent.getPreferredSize(JComponent.java:1634) at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78) at java.awt.Container.preferredSize(Container.java:1599) at java.awt.Container.getPreferredSize(Container.java:1584) at javax.swing.JComponent.getPreferredSize(JComponent.java:1636) at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702) at java.awt.Container.layout(Container.java:1421) at java.awt.Container.doLayout(Container.java:1410) at java.awt.Container.validateTree(Container.java:1507) at java.awt.Container.validate(Container.java:1480) at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQu 线程“ AWT-EventQueue-0”中的异常java.util.NoSuchElementException:java.util.Vector $ 1.nextElement(Vector.java:305)处的矢量枚举,javax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java :778)在javax.swing.JComponent.getPreferredSize(JComponent.java:1634)在javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)在java.awt.Container.preferredSize(Container.java:1599)在Java javax.swing中的.awt.Container.getPreferredSize(Container.java:1584)在java.awt.Container中的javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702)中的JComponent.getPreferredSize(JComponent.java:1636)在Javax.swing。 java.awt.Container.validateTree(Container.java:1507)的java.awt.Container.doLayout(Container.java:1410)的layout(Container.java:1421)at java.awt.Container.validate(Container.java :1480)at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)at javax.swing.SystemEventQueueUtilities $ ComponentWorkRequest.run(SystemEventQu eueUtilities.java:124) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) eueUtilities.java:124)处java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)处java.awt.EventQueue.dispatchEvent(EventQueue.java:597)处java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java) java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)处的java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)处的java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)处的:269) .awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)位于java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Problems like this generally happen when you try to update a Swing component outside of the Event Dispatch Thread (EDT). 当您尝试在事件调度线程(EDT)之外更新Swing组件时,通常会发生此类问题。

Read the section from the Swing tutorial on Concurrency for more information and the solution. 阅读Swing 并发教程中的这一节,以获取更多信息和解决方案。

Also make sure the GUI is built on the EDT by using SwingUtilities.invokeLater(...). 另外,通过使用SwingUtilities.invokeLater(...)确保GUI是在EDT上构建的。 Download any example from the Swing tutorial and you will see how this is done. 从Swing教程中下载任何示例,您将看到如何完成此操作。 Since you appear to be using a JTable start with the SimpleTableDemo from the section on "How to Use Tables". 由于您似乎正在使用JTable,因此请从“如何使用表”部分的SimpleTableDemo开始。

These links helped a lot to solve the problem 这些链接对解决问题有很大帮助

Threads and Swing 线程和摆动

Using a Swing Worker Thread 使用Swing Worker线程

The last word in Swing Threads Swing Threads中的硬道理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的程序在线程“ AWT-EventQueue-0” java.util.NoSuchElementException中说异常? - Why does my program says Exception in thread “AWT-EventQueue-0” java.util.NoSuchElementException? 错误扫描文本文件时显示错误“线程“ AWT-EventQueue-0”中的异常java.util.NoSuchElementException” - ERROR Scanning textFile shows error “ Exception in thread ”AWT-EventQueue-0“ java.util.NoSuchElementException” Java:线程“ AWT-EventQueue-0”中的异常java.util.ConcurrentModificationException - Java: Exception in thread “AWT-EventQueue-0” java.util.ConcurrentModificationException 线程“AWT-EventQueue-0”中的java异常 - java exception in thread “AWT-EventQueue-0” 线程“ AWT-EventQueue-0”中的异常(Java) - Exception in thread “AWT-EventQueue-0” (Java) 线程java.util.NoSuchElementException中的Java异常 - Java Exception in thread java.util.NoSuchElementException 线程“ AWT-EventQueue-0”中的异常java.awt.HeadlessException - Exception in thread “AWT-EventQueue-0” java.awt.HeadlessException 线程“主”中的异常java.util.NoSuchElementException? - Exception in thread “main” java.util.NoSuchElementException? 线程“主”中的异常java.util.NoSuchElementException - Exception in thread “main” java.util.NoSuchElementException 线程“主”中的异常java.util.NoSuchElementException - Exception in thread “main” java.util.NoSuchElementException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM