void (ClassMember[] elements) { ArrayList<TreePath> selectionPaths = new ArrayList<>(); for (ClassMember element : elements) { MemberNode treeNode = myElementToNodeMap.get(element); if (treeNode != null) { selectionPaths.add(new TreePath(((DefaultMutableTreeNode)treeNode).getPath())); } } final TreePath[] paths = toTreePathArray(selectionPaths); myTree.setSelectionPaths(paths); if (paths.length > 0) { TreeUtil.showRowCentered(myTree, myTree.getRowForPath(paths[0]), true, true); } }