Here you can find the source of createTree()
public static JTree createTree()
//package com.java2s; //License from project: Open Source License import javax.swing.JTree; import javax.swing.tree.DefaultMutableTreeNode; public class Main { public static JTree createTree() { DefaultMutableTreeNode top = new DefaultMutableTreeNode("home"); top.add(new DefaultMutableTreeNode("Alice")); top.add(new DefaultMutableTreeNode("Bob")); top.add(new DefaultMutableTreeNode("Eve")); JTree tree = new JTree(top); return tree; }/*from w w w .j a v a2s.co m*/ }