How to hide a node on a JTree

How can I hide a node in a JTree?
Who is Participating?
msmolyakConnect With a Mentor Commented:
You can create your own cell renderer by implementing the 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.
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.
All Courses

From novice to tech pro — start learning today.