Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTree doesn't display expanded node

803453Feb 14 2013 — edited Feb 18 2013
Hi,
I've written a JTrre extension to navigate though file-system that load node only if necessary.
That way it is really fast to load, and nothing get loaded if unnecessary.
It is like a JFileChooser;
tecnically my code is just an implementatio of TreeWillExpandListener and TreeSelectionListener that load the content of the selected node, if not already loaded (it doesn't "see" FileSystem change that way, but i don't care, and BTW it is easy to remove the "not load if loaded" check and add a "clear node content")
Every folder is a DefaultMutableTreeNode with
@Override
public boolean isLeaf(){
	return false;
}
everything works, i can navigate though tree flawlessly if starting from root node, the problem started when trying to load a saved path.

because my code load dynamically the tree, for every peace of path i just call expandNode(partialPath), i can see that node are loaded, BUT they aren't visible in the JTree swing, only the root node!.
Calling the JTree.isVisible(fullPathWithoutLeaf) return true....
Also if you double click the root node, nothing happen as like it is collapsing the subnode, then double click again and here there are the sub-node! Because they aren't loaded again, that means they was correctly loaded at the beginning!!

What i'm missing?

i've also tested (afrer calling expand on partial path):

setExpandsSelectedPaths(true);
setSelectionPath(fullPathWithoutLeaf);
makeVisible(fullPathWithoutLeaf);
expandPath(fullPathWithoutLeaf);

code:
JTree+Listener code: codepad.org/pLMrVlBd
FakeEmptyTreeNode: codepad.org/ecrfDZNV

Edited by: lesto on Feb 14, 2013 4:55 AM

Edited by: lesto on Feb 14, 2013 4:58 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 18 2013
Added on Feb 14 2013
2 comments
1,172 views