Solved

How to hide a node on a JTree

Posted on 1998-07-31
2
1,152 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java string replace 11 55
jmss example java 2 23
servlet and mdb, jms error 1 38
Fast way to search item into Java Array (Rhino compatible) 2 31
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 This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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.

828 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