List of usage examples for javax.swing.tree TreeModel getIndexOfChild
public int getIndexOfChild(Object parent, Object child);
From source file:Main.java
/** * Determines whether a path exists in a given tree model. For this to work, * the TreeModel.getIndexOfChild() method has to be correctly implemented *//*from ww w .j a v a2s .co m*/ public static boolean existsInModel(TreeModel model, TreePath path) { Object[] objects = path.getPath(); if (!objects[0].equals(model.getRoot())) return false; Object prev = objects[0]; for (int i = 1; i < objects.length; i++) { if (model.getIndexOfChild(prev, objects[i]) < 0) return false; prev = objects[i]; } return true; }