I have one program of java, which will depict you the use of JTree class of java. Please review following example :
Code:
import javax.swing.JTree;
public class TreeLinesDemo {
public static void main(String args[]) {
JFrame frameP = new JFrame("Tree Lines");
frameP.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container content = frameP.getContentPane();
Box box = Box.createHorizontalBox();
JTree tree01 = new JTree();
tree01.putClientProperty("JTree.lineStyle", "Angled");
JScrollPane scrollPane1 = new JScrollPane(tree01);
tree01.setAutoscrolls(true);
JTree tree02 = new JTree();
JScrollPane scrollPane2 = new JScrollPane(tree02);
box.add(scrollPane1, BorderLayout.WEST);
box.add(scrollPane2, BorderLayout.EAST);
frameP.getContentPane().add(box, BorderLayout.CENTER);
frameP.setSize(200, 240);
frameP.setVisible(true);
}
}
Bookmarks