-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJTreeDemo.java
More file actions
30 lines (27 loc) · 879 Bytes
/
Copy pathJTreeDemo.java
File metadata and controls
30 lines (27 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.awt.*;
import javax.swing.*;
import javax.swing.tree.*;
/* <applet code= JTreeDemo width = 300 height = 300></applet>*/
public class JTreeDemo extends JApplet
{
JTree t;
public void init(){
// Container c = getContentPane();
// c.setLayout(new BorderLayout());
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Options");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
top.add(a);
DefaultMutableTreeNode a1 = new DefaultMutableTreeNode("A1");
a.add(a1);
DefaultMutableTreeNode a2 = new DefaultMutableTreeNode("A2");
a.add(a2);
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
top.add(b);
DefaultMutableTreeNode b1 = new DefaultMutableTreeNode("B1");
b.add(b1);
DefaultMutableTreeNode b2 = new DefaultMutableTreeNode("B2");
b.add(b2);
t = new JTree(top);
add(t);
}
}