Solved

How to hide a node on a JTree

Posted on 1998-07-31
2
1,139 Views
Last Modified: 2008-02-01
How can I hide a node in a JTree?
0
Comment
Question by:srinath
2 Comments
 
LVL 2

Expert Comment

by:shchuka
Comment Utility
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
 
LVL 5

Accepted Solution

by:
msmolyak earned 100 total points
Comment Utility
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

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now