Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to hide a node on a JTree

Posted on 1998-07-31
2
Medium Priority
?
1,205 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
ID: 1229648
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
ID: 1229649
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

824 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