How to hide a node on a JTree

How can I hide a node in a JTree?
srinathAsked:
Who is Participating?
 
msmolyakConnect With a Mentor Commented:
You can create your own cell renderer by implementing the com.sun.java.swing.tree.TreeCellRenderer interface (or even better, extending the basic cell renderer used by Swing). In getTreeCellRendererComponent() method before returning the component make it invisible (setVisible(false)) if the node (passed there as value parameter) requires that.

Or you can temporarily remove the node from the tree.
0
 
shchukaCommented:
I'm not sure it's possible at all.  (Assuming, you are talking about the swint JTree component.)  The only node you can hide is the root node.  Use the .setRootVisible(boolean b) method to do so.
0
All Courses

From novice to tech pro — start learning today.