File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Exception in JTree updating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Exception in JTree updating " Watch "Exception in JTree updating " New topic

Exception in JTree updating

Nasir Ahamed

Joined: Mar 17, 2006
Posts: 1
I have constructed a tree and when ever any change occured to the tree i am sending an event from server which will notify all the clients.
Then the tree is refreshed by using TreeModelEvent methods like nodeInserted, nodesRemoved, nodesModified etc.

The no of events generated are so many that if there are 20 nodes then for each second say for each node there will be 10 updates.

At this time i am getting exception saying

java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
at java.util.Vector.elementAt(
at javax.swing.tree.DefaultMutableTreeNode.getChildAt(
at javax.swing.tree.VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration.updateNextIndex(
at javax.swing.tree.VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration.updateNextObject(
at javax.swing.tree.VariableHeightLayoutCache$VisibleTreeStateNodeEnumeration.nextElement(
at javax.swing.plaf.basic.BasicTreeUI.paint(
at javax.swing.plaf.metal.MetalTreeUI.paint(
at javax.swing.plaf.ComponentUI.update(
at javax.swing.JComponent.paintComponent(
at javax.swing.JComponent.paint(
at javax.swing.JComponent.paintWithOffscreenBuffer(
at javax.swing.JComponent.paintDoubleBuffered(
at javax.swing.JComponent._paintImmediately(
at javax.swing.JComponent.paintImmediately(
at javax.swing.RepaintManager.paintDirtyRegions(
at javax.swing.SystemEventQueueUtilities$
at java.awt.event.InvocationEvent.dispatch(
at java.awt.EventQueue.dispatchEvent(
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(
at java.awt.EventDispatchThread.pumpEventsForHierarchy(
at java.awt.EventDispatchThread.pumpEvents(
at java.awt.EventDispatchThread.pumpEvents(

This is a big problem for me and i have to fix it as early as possible.

Thanks in advance
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

I have the same bug and it is *very* hard to reproduce but appears to be a Swing bug. Here's my stack trace:

I've searched google and the usual places and read through the source, but no luck. It appears to be a threading error, the thread from the stack trace shown makes a request to view the last element of an array but sometime between getting the index and accessing the data, the array is decrement by one.

None of my code modifies the tree (that I'm aware of).

Could use some help on this one.
[ June 16, 2006: Message edited by: Scott Selikoff ]

[OCA 8 Book] [Blog]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
Nasir Ahamed, welcome to the Ranch.

I presume you have been through the lines quoted, and investigated the usual suspects? Your error message 0 >= 0 suggests you have a zero-member array.

Are you sure this really is a bug? If you think it is, have you checked the bugs database?

I agree. Here's the link:
subject: Exception in JTree updating
It's not a secret anymore!