Here you can find the source of isFile(TreePath path)
public static boolean isFile(TreePath path)
//package com.java2s; //License from project: Open Source License import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; public class Main { public static boolean isFile(TreePath path) { DefaultMutableTreeNode clickedNode = (DefaultMutableTreeNode) path.getLastPathComponent(); return (!clickedNode.getAllowsChildren()); }/*w ww . java 2 s .c om*/ }