public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node; node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent()); /* * If the event lists children, then the changed * node is the child of the node we've already * gotten. Otherwise, the changed node and the * specified node are the same. */ int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); System.out.println("The user has finished editing the node."); System.out.println("New value: " + node.getUserObject()); }
private DefaultMutableTreeNode findIDorURL(DefaultMutableTreeNode node, ID id, URL url) { SearchTOCItem item = (SearchTOCItem) node.getUserObject(); if (item != null) { ID testID = item.getID(); if (testID != null && id != null && testID.equals(id)) { return node; } else { URL testURL = item.getURL(); if (testURL != null && url != null && url.sameFile(testURL)) { return node; } } } int size = node.getChildCount(); for (int i = 0; i < size; i++) { DefaultMutableTreeNode tmp = (DefaultMutableTreeNode) node.getChildAt(i); DefaultMutableTreeNode test = findIDorURL(tmp, id, url); if (test != null) { return test; } } return null; }