Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JTree drag n drop / remove error

1 view
Skip to first unread message

Glenn Ivar Klausen

unread,
Jan 28, 2003, 9:37:14 AM1/28/03
to
I get this exceptions when i either drag n drop a node or when a node is
delted. However, this happens only when the tree is updated with new
nodes after start up. If it is setup during the init of the application,
it works.

The only difference in code betwenn start up and when a node is is added
is the lines below

Anybode who knows?

// these two line are the only difference between start up and
// inserting nodes at runtime.
DefaultMutableTreeNode root = new DefaultMutableTreeNode("XXXX");

m_treeModel = new DefaultTreeModel(root);

// this call fails
((DefaultTreeModel)this.getModel()).removeNodeFromParent(currentNode);

// with this exception
java.lang.ArrayIndexOutOfBoundsException: 1 >= 1
at java.util.Vector.elementAt(Unknown Source)
at javax.swing.tree.DefaultMutableTreeNode.getChildAt(Unknown Source)
at javax.swing.tree.VariableHeightLayoutCache.treeNodesRemoved(Unknown
Source)
at
javax.swing.plaf.basic.BasicTreeUI$TreeModelHandler.treeNodesRemoved(Unknown
Source)
at javax.swing.tree.DefaultTreeModel.fireTreeNodesRemoved(Unknown Source)
at javax.swing.tree.DefaultTreeModel.nodesWereRemoved(Unknown Source)
at javax.swing.tree.DefaultTreeModel.removeNodeFromParent(Unknown Source)
at no.zeroone.zoac.gui.JHostInfo$5.actionPerformed(JHostInfo.java:210)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown
Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Glenn

Christian Kaufhold

unread,
Jan 28, 2003, 2:40:17 PM1/28/03
to
Hello!

Glenn Ivar Klausen <glenn....@oslo.online.no> wrote:

> I get this exceptions when i either drag n drop a node or when a node is
> delted. However, this happens only when the tree is updated with new
> nodes after start up. If it is setup during the init of the application,
> it works.

You probably are not adding new nodes properly somewhere (not using
DefaultTreeModel.insertNodeInto), therefore BasicTreeUI does not know
about these nodes).


Christian

Glenn Ivar Klausen

unread,
Jan 29, 2003, 4:21:39 AM1/29/03
to
Christian Kaufhold wrote:
> Hello!

>
> You probably are not adding new nodes properly somewhere (not using
> DefaultTreeModel.insertNodeInto), therefore BasicTreeUI does not know
> about these nodes).

Thanks, all I had to do was a treeModel.relaoad(root);

Then it worked :)

Glenn

Christian Kaufhold

unread,
Jan 29, 2003, 5:53:10 PM1/29/03
to
Hello!

Glenn Ivar Klausen <glenn....@oslo.online.no> wrote:

That sounds like a workaround for not doing the proper thing somewhen
earlier.

Christian

0 new messages