Practical 7 updated

 avatar
Rohit143
java
2 years ago
1.3 kB
3
Indexable
Never
import java.awt.BorderLayout;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
class MyJFrame extends JFrame{
    JTree tree;
    DefaultMutableTreeNode root,sem3,sem4,dms,jpr,ajp,css;
    JScrollPane scrollPane;

    MyJFrame(){
        JLabel label=new JLabel("Rohit Nandagawali");
         add(label,BorderLayout.NORTH);
        root= new DefaultMutableTreeNode("semester Subjects");

        sem3 = new DefaultMutableTreeNode("semister 3");
        sem4 = new DefaultMutableTreeNode("semister 4");

        dms=new DefaultMutableTreeNode("DMS");
        jpr=new DefaultMutableTreeNode("JPR");

        ajp=new DefaultMutableTreeNode("AJP");
        css=new DefaultMutableTreeNode("CSS");

        root.add(sem3);
        root.add(sem4);

        sem3.add(dms);
        sem3.add(jpr);

        sem4.add(ajp);
        sem4.add(css);

        tree = new JTree(root);
        scrollPane = new JScrollPane(tree);
        add(scrollPane,BorderLayout.CENTER);

        

        setVisible(true);
        setSize(400, 500);
        setDefaultCloseOperation(EXIT_ON_CLOSE);

        
        
    }
}
public class practical7 {
    
    public static void main(String[] args) {
        
        new MyJFrame();
    }
}