java - JTree: Missing link between TreeNode and TreePath -


i have problem described here.

i have invertexpand method in mytree class works this:

public void invertexpand(defaultmutabletreenode node) {     treepath path = new treepath(node.getpath()); // no better way treepath treenode :(     if (!isexpanded(path)) {         expandpath(path);     } else {         collapsepath(path);     } } 

but problem isexpanded() method uses hashmap store expanded paths. seems isexpanded() never returns true newly created treepath. (but expanded really)

does way fix issue?

expand/collapse works on non-leaf nodes, sure node in question not leaf:

public void invertexpand(defaultmutabletreenode node) {     if (node.isleaf())          node = (defaultmutabletreenode) node.getparent();     treepath path = new treepath(node.getpath()); // no better way treepath treenode :(     if (isexpanded(path)) {         collapsepath(path);     } else {         expandpath(path);     } } 

edit (as per op's comment)

the real reason misbehaviour incorrectly implemented hascode in custom node confused map (where expanded paths stored).


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -