J
Jason Cavett
I'm having an issue when adding a new node to a JTree. Here's the
code in question:
this.setEditable(true);
if (parent == null) {
treeModel.insertNodeInto(child, rootNode, rootNode.getChildCount());
} else {
treeModel.insertNodeInto(child, parent, parent.getChildCount());
}
this.setEditable(false);
I then call "expandPath(e.getTreePath())" inside the TreeModelListener
that I have added to treeModel (which is my own DefaultTreeModel).
Unfortunately, when I do this expandPath, there appears to be an extra
row in the tree. Something like this:
Root
- Item1
- Item2
[BLANK ROW]
- Item3
From the research I did, it appears to be a problem with the
userObject (based on this discussion:
http://www.javakb.com/Uwe/Forum.aspx/java-gui/6527/JTree-display-update-issue-with-new-nodes),
but I'm really having a problem fixing it. I definitely need the
expandPath to happen, so I'm not sure what else to do.
Anybody have any suggestions on fixing this?
Thanks!
code in question:
this.setEditable(true);
if (parent == null) {
treeModel.insertNodeInto(child, rootNode, rootNode.getChildCount());
} else {
treeModel.insertNodeInto(child, parent, parent.getChildCount());
}
this.setEditable(false);
I then call "expandPath(e.getTreePath())" inside the TreeModelListener
that I have added to treeModel (which is my own DefaultTreeModel).
Unfortunately, when I do this expandPath, there appears to be an extra
row in the tree. Something like this:
Root
- Item1
- Item2
[BLANK ROW]
- Item3
From the research I did, it appears to be a problem with the
userObject (based on this discussion:
http://www.javakb.com/Uwe/Forum.aspx/java-gui/6527/JTree-display-update-issue-with-new-nodes),
but I'm really having a problem fixing it. I definitely need the
expandPath to happen, so I'm not sure what else to do.
Anybody have any suggestions on fixing this?
Thanks!