|
Hi All, I’m experiencing a problem with a JTree which is
really baffling me. I’m trying to insert a node into a JTree on a specific
user action using this code (taken from The Java Tutorial). public DefaultMutableTreeNode
addObject(DefaultMutableTreeNode parent,
Object child,
boolean shouldBeVisible) {
DefaultMutableTreeNode childNode =
new DefaultMutableTreeNode(child); if (parent ==
null) {
parent = rootNode; } treeModel.insertNodeInto(childNode,
parent,
parent.getChildCount()); //Make sure the
user can see the lovely new node. if
(shouldBeVisible) {
tree.scrollPathToVisible(new TreePath(childNode.getPath())); } return childNode; } The problem is that the newly added node doesn’t
display in the JTree??! I’ve even added this to check that a node was in fact
added: return (DefaultMutableTreeNode)fTreeModel.getChild(rootNode,
parent.getChildCount()-1); and it returns the node that was added. But the JTree doesn’t display the node. Any ideas what I’m doing wrong? Enrico Goosen Software Developer SAICOM TECHNOLOGY TEL: +2721
555 0726 FAX: +2721 555 0821 CEL: +2783 305 5676 EMAIL: [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CTJUG Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/CTJUG-Forum -~----------~----~----~----~------~----~------~--~--- |
- [CTJUG Forum] JTree problem Enrico Goosen
- [CTJUG Forum] Re: JTree problem Carl Olivier
- [CTJUG Forum] Re: JTree problem Enrico Goosen
- [CTJUG Forum] Re: JTree problem Ben van der Merwe
- [CTJUG Forum] Re: JTree problem Enrico Goosen
- [CTJUG Forum] Re: JTree problem Ben van der Merwe
