TemplateImpl (int row) { JTree tree = myTree; TreePath path = tree.getPathForRow(row); if (path != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent(); if (node.getUserObject() instanceof TemplateImpl) { return (TemplateImpl)node.getUserObject(); } } return null; }