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