D
dushkin
Hi,
I uses JTree in my code.
From time to time I remove a node and insert a new node instead of
it.
I use the object ID to follow the changes while debugging.
For example, before I make the changes the nodes IDs are as follows:
Root
Node 1 (7cb)
Node 2 (7db)
Node 3 (7eb)
Node 4 (7fb)
Now, The scenrio was is as follows:
Click Node1 --> Click Node2 --> Click Node1 --> Click Node2
After removing and inserting the first 2 nodes (after those clicks)
the tree looks like this:
Root
Node 1 (80b)
Node 2 (8ab)
Node 3 (7eb)
Node 4 (7fb)
and here comes the oditty...
After each click which fires the remove and insertin of nodes, I have
the following code:
//**********************************************************************************
DefaultMutableTreeNode mapMutNode = null;
TreePath selPath =
xTreeScm.getPathForLocation(e.getX(), e.getY());
if (selPath.getLastPathComponent() == null) {
return;
} else {
printlnTree();
DefaultMutableTreeNode mapMutNode =
selPath.getLastPathComponent();
int i =
xTreeScm.getModel().getIndexOfChild(xTreeScm.getRootNode(),
mapMutNode);
//**********************************************************************************
mapMutNode returns me the replaced 7cb node instead of the new 80b node
!!!
Moreover, the following getIndexOfChild() return -1 !
Can someone advise please? Thanks
I uses JTree in my code.
From time to time I remove a node and insert a new node instead of
it.
I use the object ID to follow the changes while debugging.
For example, before I make the changes the nodes IDs are as follows:
Root
Node 1 (7cb)
Node 2 (7db)
Node 3 (7eb)
Node 4 (7fb)
Now, The scenrio was is as follows:
Click Node1 --> Click Node2 --> Click Node1 --> Click Node2
After removing and inserting the first 2 nodes (after those clicks)
the tree looks like this:
Root
Node 1 (80b)
Node 2 (8ab)
Node 3 (7eb)
Node 4 (7fb)
and here comes the oditty...
After each click which fires the remove and insertin of nodes, I have
the following code:
//**********************************************************************************
DefaultMutableTreeNode mapMutNode = null;
TreePath selPath =
xTreeScm.getPathForLocation(e.getX(), e.getY());
if (selPath.getLastPathComponent() == null) {
return;
} else {
printlnTree();
DefaultMutableTreeNode mapMutNode =
selPath.getLastPathComponent();
int i =
xTreeScm.getModel().getIndexOfChild(xTreeScm.getRootNode(),
mapMutNode);
//**********************************************************************************
mapMutNode returns me the replaced 7cb node instead of the new 80b node
!!!
Moreover, the following getIndexOfChild() return -1 !
Can someone advise please? Thanks