Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Enumeration;

import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreePath;

public class Main {
    public static void main(String[] args) {
        JTree tree = new JTree();
        Enumeration en = ((DefaultMutableTreeNode) tree.getModel().getRoot()).preorderEnumeration();
        while (en.hasMoreElements()) {
            TreePath path = new TreePath(((DefaultMutableTreeNode) en.nextElement()).getPath());
            String text = path.toString();
            System.out.println(text);
        }
    }
}