Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Example Java Swing Tree Root Hide in Java

Related Tutorials


 
 

Share on Google+Share on Google+

Tree Root Hide in Java

Advertisement
In this section, you will learn to hide the root node of a JTree.

Tree Root Hide in Java

     

In this section, you will learn to hide the root node of  a JTree

Description of the Program:

The following program helps to hide the root node of the Jtree component. This program creates a tree that contains multiple nodes where the root node is kept hidden. The getProperty() method determines the current system properties. This method returns the multiple data of system that will be displayed in a node. For hiding root node we set the setRootVisible is 'false'. 

Here is the code of this program:

import javax.swing.*;
import javax.swing.event.*;
import java.util.Properties;
import javax.swing.JTree.*;

public class TreeRootHide{
  public static void main(String[] args) {
  JFrame frame = new JFrame("Root Hide of tree");
  Properties prop = System.getProperties();
  JTree tree = new JTree(prop);
  tree.setRootVisible(false);
  JScrollPane scroll = new JScrollPane(tree);
  frame.getContentPane().add(scroll, "Center");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
  frame.setSize(350,400);
  frame.setVisible(true);
  }
}

Download this program.

Output this program:

 

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 30, 2007

Related Tutorials

Discuss: Tree Root Hide in Java  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com