2012-01-20 81 views
0

我在重繪對象列表時遇到以下異常。我無法找到此錯誤發生的位置,因爲我看不到對應用程序文件的引用。繪製列表時發生Java錯誤

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1 
    at java.util.Vector.elementAt(Vector.java:341) 
    at javax.swing.tree.VariableHeightLayoutCache.updateNodeSizes(VariableHeightLayoutCache.java:908) 
    at javax.swing.tree.VariableHeightLayoutCache.getBounds(VariableHeightLayoutCache.java:212) 
    at javax.swing.plaf.basic.BasicTreeUI.getPathBounds(BasicTreeUI.java:521) 
    at javax.swing.plaf.basic.BasicTreeUI.paint(BasicTreeUI.java:1184) 
    at javax.swing.plaf.ComponentUI.update(ComponentUI.java:154) 
    at javax.swing.JComponent.paintComponent(JComponent.java:763) 
    at javax.swing.JComponent.paint(JComponent.java:1040) 
    at javax.swing.JComponent.paintChildren(JComponent.java:873) 
    at javax.swing.JComponent.paint(JComponent.java:1049) 
    at javax.swing.JViewport.paint(JViewport.java:758) 
    at javax.swing.JComponent.paintChildren(JComponent.java:873) 
    at javax.swing.JComponent.paint(JComponent.java:1049) 
    at javax.swing.JComponent.paintToOffscreen(JComponent.java:5135) 
    at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1490) 
    at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1421) 
    at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:305) 
    at javax.swing.RepaintManager.paint(RepaintManager.java:1235) 
    at javax.swing.JComponent._paintImmediately(JComponent.java:5083) 
    at javax.swing.JComponent.paintImmediately(JComponent.java:4893) 
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:796) 
    at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:724) 
    at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:704) 
    at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:136) 
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:220) 
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:650) 
    at java.awt.EventQueue.access$000(EventQueue.java:95) 
    at java.awt.EventQueue$1.run(EventQueue.java:613) 
    at java.awt.EventQueue$1.run(EventQueue.java:611) 
    at java.security.AccessController.doPrivileged(AccessController.java:224) 
    at com.ibm.oti.security.CheckedAccessControlContext.securityCheck(CheckedAccessControlContext.java:30) 
    at sun.misc.JavaSecurityAccessWrapper.doIntersectionPrivilege(JavaSecurityAccessWrapper.java:29) 
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:621) 
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:280) 
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:195) 
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:185) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:180) 
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:172) 
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:133) 

回答

1

there are two issues

1)畫到存在比等待時間更快從本機OS

2)出界的DirtyRegions,F.E.在Win OS(cca)上更新速度超過30毫秒

小問題如果在那裏存在,你是否實現了一些Custom Look and Feels

請編輯您的帖子的代碼,在SSCCE形式

+0

+1本文引用的文章提出了幾種識別EDT違規的方法。 – trashgod

1

產生的異常從RepaintManager中,如果您要改變的節點在另一個線程,線程併發可能是你的問題。如果這是您的問題,那麼使用SwingUtilities.invokeLater來操作樹節點將確保可見節點的任何更改都將在擺動線程上進行。

+1

+1,這也是我的猜測。海報應該閱讀Swing [Swing中的併發]教程(http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html)以更好地理解潛在問題。 – camickr

相關問題