Search code examples
javamysqlswingjtreetreenode

How can I delete exactly node in JTree?


I have a tree like this:

-root
 -grandParent1
  -parent1
   -child1
   ....
 -grandParent2
  -parent1
   -child1
   ....

How can I delete exactly grandParent1-parent1-child1 in database? At first, I distinguish child name with parent, but if parent have same name is problem.


Solution

  • I distinguish child name with parent, but..

    ..should be identifying them by their entire path (which is unique for every tree node)!

    See, for example, JTree.getPathForRow(int)1 which returns a TreePath2.

    1. Returns the path for the specified row. .."
    2. TreePath represents an array of objects that uniquely identify the path to a node in a tree.