Tree Making with Java Swing in Eclipse
Tree Making with Java Swing in Eclipse:
https://youtu.be/5fwYjXjekAI ________________________________________________ How to Tree Making with Java Swing in Eclipse?
package Test;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
public class Tree {
JFrame f;
Tree(){
f = new JFrame();
DefaultMutableTreeNode eatingsTree = new DefaultMutableTreeNode("Eatings");
DefaultMutableTreeNode vegetableTree = new DefaultMutableTreeNode("Vegetables");
DefaultMutableTreeNode fruitTree = new DefaultMutableTreeNode("Fruits");
eatingsTree.add(vegetableTree);
eatingsTree.add(fruitTree);
DefaultMutableTreeNode potato = new DefaultMutableTreeNode ("Potato");
DefaultMutableTreeNode salad = new DefaultMutableTreeNode ("Salad");
DefaultMutableTreeNode apple = new DefaultMutableTreeNode ("Apple");
DefaultMutableTreeNode orange = new DefaultMutableTreeNode ("Orange");
vegetableTree.add(potato);
vegetableTree.add(salad);
fruitTree.add(apple);
fruitTree.add(orange);
JTree tree1 = new JTree(eatingsTree);
f.add(tree1);
f.setSize(200,200);
f.setVisible(true);
f.setLocation(600,150);
}
public static void main(String[] args) {
new Tree();
}
}
________________________________________________
Dark Hers
YouTube
https://instagram.com/darkhers
https://www.facebook.com/darkhers
TikTok
https://www.tiktok.com/@darkhers
https://www.pinterest.co.uk/darkhers
Comments
Post a Comment