0% found this document useful (0 votes)
2 views

Code JTree

Uploaded by

sanchita bansode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Code JTree

Uploaded by

sanchita bansode
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import javax.swing.

*;

import javax.swing.tree.*;

class TreeExample{

JFrame f;

TreeExample() {

JFrame f=new JFrame ("university");

DefaultMutableTreeNode uni=new DefaultMutableTreeNode("University");

DefaultMutableTreeNode pcp=new DefaultMutableTreeNode("Pimpri Chinchwad Polytechnic");

DefaultMutableTreeNode ps=new DefaultMutableTreeNode("Pratibha School");

uni.add(pcp);

uni.add(ps);

DefaultMutableTreeNode Comp=new DefaultMutableTreeNode("Computer");

DefaultMutableTreeNode IT=new DefaultMutableTreeNode("IT");

DefaultMutableTreeNode Mech=new DefaultMutableTreeNode("Mechanical");

pcp.add(Comp);

pcp.add(IT);

pcp.add(Mech);

DefaultMutableTreeNode BE=new DefaultMutableTreeNode("BE");

DefaultMutableTreeNode Bcom=new DefaultMutableTreeNode("Bcom");

DefaultMutableTreeNode BTech=new DefaultMutableTreeNode("BTech");

ps.add(BE);

ps.add(Bcom);

ps.add(BTech);

JTree jt=new JTree(uni);

f.add(jt);

f.setSize(400,400);

f.setVisible(true);

}}

public class TreeDemo

public static void main (String[]args)

new TreeExample();

You might also like