问题描述
异常一Exceptioninthread"AWT-EventQueue-0"java.util.NoSuchElementException:VectorEnumerationatjava.util.Vector$1.nextElement(Vector.java:305)atjavax.swing.plaf.basic.BasicTableUI.getPreferredSize(BasicTableUI.java:1684)atjavax.swing.JComponent.getPreferredSize(JComponent.java:1634)atjavax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:769)atjava.awt.Container.layout(Container.java:1421)atjava.awt.Container.doLayout(Container.java:1410)atjava.awt.Container.validateTree(Container.java:1507)atjava.awt.Container.validate(Container.java:1480)atjavax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)atjavax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)atjava.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)atjava.awt.EventQueue.dispatchEvent(EventQueue.java:597)atjava.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)atjava.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)atjava.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)atjava.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)atjava.awt.EventDispatchThread.run(EventDispatchThread.java:122)异常二Exceptioninthread"AWT-EventQueue-0"java.lang.ArrayIndexOutOfBoundsException:0>=0atjava.util.Vector.elementAt(Vector.java:427)atjavax.swing.table.DefaultTableColumnModel.getColumn(DefaultTableColumnModel.java:277)atjavax.swing.plaf.basic.BasicTableHeaderUI.getHeaderRenderer(BasicTableHeaderUI.java:677)atjavax.swing.plaf.basic.BasicTableHeaderUI.getHeaderHeight(BasicTableHeaderUI.java:721)atjavax.swing.plaf.basic.BasicTableHeaderUI.createHeaderSize(BasicTableHeaderUI.java:750)atjavax.swing.plaf.basic.BasicTableHeaderUI.getPreferredSize(BasicTableHeaderUI.java:781)atjavax.swing.JComponent.getPreferredSize(JComponent.java:1634)atjavax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)atjava.awt.Container.preferredSize(Container.java:1599)atjava.awt.Container.getPreferredSize(Container.java:1584)atjavax.swing.JComponent.getPreferredSize(JComponent.java:1636)atjavax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702)atjava.awt.Container.layout(Container.java:1421)atjava.awt.Container.doLayout(Container.java:1410)atjava.awt.Container.validateTree(Container.java:1507)atjava.awt.Container.validate(Container.java:1480)atjavax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)atjavax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)atjava.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)atjava.awt.EventQueue.dispatchEvent(EventQueue.java:597)atjava.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)atjava.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)atjava.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)atjava.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)atjava.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)atjava.awt.EventDispatchThread.run(EventDispatchThread.java:122)下面是我单独起的一个线程,专门用来刷新页面上的jtable的publicclassRefreshThreadimplementsRunnable{privateJTablezsjTable;privateJTextFieldsxjTextField1;publicRefreshThread(JTablezsjTable,JTextFieldsxjTextField1){super();this.zsjTable=zsjTable;this.sxjTextField1=sxjTextField1;}@Overridepublicvoidrun(){PublicParamter.getInstence().setClickrefresh(false);//每10秒执行一次线程while(!(PublicParamter.getInstence().isClickrefresh())){ArrayList<ReStatusBean>list=newArrayList<ReStatusBean>();try{inttime=10;if(!("".equals(sxjTextField1.getText()))){time=Integer.parseInt(sxjTextField1.getText());}Thread.sleep(time*1000);//取单例的map属性中的数据,用于页面显示HashMap<String,ReStatusBean>map=PublicParamter.getInstence().getMap();Iterator<Map.Entry<String,ReStatusBean>>iter=map.entrySet().iterator();while(iter.hasNext()){Map.Entry<String,ReStatusBean>entry=(Map.Entry<String,ReStatusBean>)iter.next();Stringname=(String)entry.getKey();ReStatusBeanvalue=map.get(name);list.add(value);}//构建Jtable展示的数据模型String[][]data=newString[list.size()][];for(inti=0;i<list.size();i++){ArrayList<String>shuxinglist=newArrayList<String>();shuxinglist.add(list.get(i).getName());shuxinglist.add(list.get(i).getPath());shuxinglist.add(list.get(i).getCurrentStatus());shuxinglist.add(list.get(i).getIdealStatus());shuxinglist.add(Integer.toString(list.get(i).getNum()));String[]shuxingdata=newString[5];shuxingdata=shuxinglist.toArray(shuxingdata);data[i]=shuxingdata;}TableModeldataModel=newDefaultTableModel(data,newString[]{"名称","路径","当前状态","理想状态","次数","操作"});zsjTable.setModel(dataModel);//重写构造器。用于在table最后一列显示按钮zsjTable.getColumnModel().getColumn(5).setCellRenderer(newMyButtonRender());zsjTable.getColumnModel().getColumn(0).setPreferredWidth(120);zsjTable.getColumnModel().getColumn(0).setMaxWidth(120);zsjTable.getColumnModel().getColumn(0).setMinWidth(120);zsjTable.getColumnModel().getColumn(1).setPreferredWidth(300);zsjTable.getColumnModel().getColumn(1).setMaxWidth(300);zsjTable.getColumnModel().getColumn(1).setMinWidth(300);zsjTable.getColumnModel().getColumn(5).setPreferredWidth(90);zsjTable.getColumnModel().getColumn(5).setMaxWidth(90);zsjTable.getColumnModel().getColumn(5).setMinWidth(90);}catch(InterruptedExceptione){e.printStackTrace();}}}}
解决方案
解决方案二:
你调试看看吧。Vector在那里
解决方案三:
引用1楼rui888的回复:
你调试看看吧。Vector在那里
我走debug,走不出来。刚网上查了好久,都说是迭代器迭代失败。可能是别的线程也操作了容器,需要加锁。但我不知道怎么处理
解决方案四:
有没有人。急救!
解决方案五:
我也遇到这个问题不知道你解决了没用其实是swing线程导致的
解决方案六:
该回复于2014-09-22 08:47:52被版主删除