Search code examples
javaswingtreejtree

JTree two nodes with same name can't be differentiated with getSelectedPath


I have two working JTrees and i can edit/delete/add nodes by drag and drop from one tree to another. But one of my trees has two nodes with same name. Irrelevant to which of the two nodes I select, the deletion always delete the first node based on the name. I cant give numbers since nested nodes have complexity on defining it.

How to solve this issue?


Solution

  • I think it uses equals() method of the objects. Try to override the method to provide the difference between nodes with the same name.