JTree: One of the most interesting new classes that Swing offers is the JTree class. this class implements a tree-like structure that can be used to display data hierarchical. TreeNode interface defines the methods that must be implemented nodes a JTree object. The class provides a DefaulMutableTreeNode default implementation of the TreeNode interface. The trees are created constructing the TreeNode interface objects and then add them all together (through of ()) method add. When all TreeNode objects have been assembled, the object Resulting TreeNode to JTree constructor is passed.
The default presentation of a JTree object uses a folder icon with the identify the tree nodes having lower nodes and a file icon to identify tree branches. The setCellRenderer () method of the class JTree is used to identify an alternative delivery tree.
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
public class JavaExampleTreeInJApplet extends JApplet
{
public void init()
{
JTree Tree = new JTree();
getContentPane().add(new JScrollPane(Tree));
}
}
/*<APPLET CODE =JavaExampleTreeInJApplet.class WIDTH=350 HEIGHT=280> </APPLET>*/