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
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
Thanks, all I had to do was a treeModel.relaoad(root);
Then it worked :)
Glenn
Glenn Ivar Klausen <glenn....@oslo.online.no> wrote:
That sounds like a workaround for not doing the proper thing somewhen
earlier.
Christian