for (int i = 0; i < paths.length; i++) { DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent(); Object o = selNode.getUserObject(); if (leafClass.isInstance(o)) { result.add(o); } else if (o instanceof String) { for (Enumeration e = selNode.depthFirstEnumeration(); e.hasMoreElements(); ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); o = node.getUserObject(); if (leafClass.isInstance(o)) { result.add(o); } } } } return result.toArray((Object[]) Array.newInstance(leafClass, result.size()));
for (int i = 0; i < paths.length; i++) { DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent(); Object o = selNode.getUserObject(); if (leafClass.isInstance(o)) { result.add(o); } else if (o instanceof String) { for (Enumeration e = selNode.depthFirstEnumeration(); e.hasMoreElements(); ) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement(); o = node.getUserObject(); if (leafClass.isInstance(o)) { result.add(o); } } }
    private Object[] fill(List result, Class leafClass, TreePath[] paths) {        for (int i = 0; i < paths.length; i++) {            DefaultMutableTreeNode selNode =                (DefaultMutableTreeNode) paths[i].getLastPathComponent();            Object o = selNode.getUserObject();            if (leafClass.isInstance(o)) {                result.add(o);            } else if (o instanceof String) {                for (Enumeration e = selNode.depthFirstEnumeration(); e.hasMoreElements(); ) {                    DefaultMutableTreeNode node =                        (DefaultMutableTreeNode) e.nextElement();                    o = node.getUserObject();                    if (leafClass.isInstance(o)) {                        result.add(o);                    }                }            }        }        return result.toArray((Object[]) Array.newInstance(leafClass, result.size()));    }