<分区>
我有一棵这样的树:
-root
-grandParent1
-parent1
-child1
....
-grandParent2
-parent1
-child1
....
如何删除数据库中的 grandParent1-parent1-child1?起初,我将 child 的名字与 parent 的名字区分开来,但如果 parent 有相同的名字,那就有问题了。
<分区>
我有一棵这样的树:
-root
-grandParent1
-parent1
-child1
....
-grandParent2
-parent1
-child1
....
如何删除数据库中的 grandParent1-parent1-child1?起初,我将 child 的名字与 parent 的名字区分开来,但如果 parent 有相同的名字,那就有问题了。
最佳答案
I distinguish child name with parent, but..
..应该通过它们的整个路径(对于每个树节点都是唯一的)来识别它们!
参见,例如,JTree.getPathForRow(int)
1 返回 TreePath
2.
- Returns the path for the specified row. .."
TreePath
represents an array of objects that uniquely identify the path to a node in a tree.
关于java - 如何准确删除 JTree 中的节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27633292/