SAE31_2023/JTreeExample.java

46 lines
1.4 KiB
Java
Raw Normal View History

2023-11-17 15:39:10 +01:00
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
/**
*
* @author elyse
*/
import javax.swing.*;
import java.awt.*;
import javax.swing.tree.DefaultMutableTreeNode;
public class JTreeExample {
JTreeExample (){
JFrame f=new JFrame("TROUVER LE DIPLOME POUR FAIRE DE L'ART");
f.setLayout(new FlowLayout());
DefaultMutableTreeNode coll= new DefaultMutableTreeNode("college");
DefaultMutableTreeNode as= new DefaultMutableTreeNode("arts & sciences");
DefaultMutableTreeNode en= new DefaultMutableTreeNode("Engineering");
DefaultMutableTreeNode ba= new DefaultMutableTreeNode("Ba");
DefaultMutableTreeNode bs= new DefaultMutableTreeNode("BSc");
DefaultMutableTreeNode bc= new DefaultMutableTreeNode("BCOM");
DefaultMutableTreeNode be= new DefaultMutableTreeNode("BE");
DefaultMutableTreeNode bt= new DefaultMutableTreeNode("BTech");
JTree tree=new JTree(coll);
en.add(be);en.add(bt);
as.add(ba);as.add(bs);as.add(bc);
coll.add(as);coll.add(en);
f.add(tree);
tree.setToggleClickCount(1);
System.out.println("click;"+tree.getToggleClickCount());
f.setSize(200 , 200 );
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new JTreeExample ();
}
}