import java.awt.*;
import javax.swing.*;
public class
import javax.swing.*;
import java.awt.*;
import javax.swing.tree.*;
import javax.swing.event.*;
public class JT extends JApplet {
JTree tree;
JTextField box;
Object nodeInfo;
String node1;
public void init() {
Container c=getContentPane();
c.setLayout(new BorderLayout());
DefaultMutableTreeNode topNode=new DefaultMutableTreeNode("qiscet");
DefaultMutableTreeNode cou=new DefaultMutableTreeNode("Courses");
DefaultMutableTreeNode mca=new DefaultMutableTreeNode("MCA");
DefaultMutableTreeNode mba=new DefaultMutableTreeNode("MBA");
DefaultMutableTreeNode tech=new DefaultMutableTreeNode("B.tech");
topNode.add(cou);
cou.add(mca);
cou.add(mba);
cou.add(tech);
DefaultMutableTreeNode manage=new DefaultMutableTreeNode("Management");
DefaultMutableTreeNode ac=new DefaultMutableTreeNode("Accounts");
DefaultMutableTreeNode sp=new DefaultMutableTreeNode("Sports");
DefaultMutableTreeNode lib=new DefaultMutableTreeNode("Library");
topNode.add(manage);
manage.add(ac);
manage.add(sp);
manage.add(lib);
tree=new JTree(topNode);
c.add(tree,BorderLayout.NORTH);
box=new JTextField("",80);
c.add(box,BorderLayout.SOUTH);
}
}
My question is not used "Container c = getContentPane ();" I get the correct result. How is this possible? What is the reason for this?
source
share