Article View: borland.public.jbuilder.java.swing
Article #11459Re: removing a node from a JTree
From: Sjaak Wolfert
Date: Fri, 21 May 1999 00:00
Date: Fri, 21 May 1999 00:00
52 lines
1813 bytes
1813 bytes
Dear Stephan, The trick is that you must not call methods of the TreeNode but of the TreeModel: DefaultTreeModel myTreeModel = new DefaultTreeModel(); ... myTreeModel.removeNodeFromParent(selectedNode); good luck, Sjaak Wolfert Stephan Grimm wrote in message <37427B5A.B85EEA55@mgm-edv.de>... >I have some problems in removing a TreeNode from a JTree. >I'm using DefaultMutableTreeNode as class for the Node-Objects and tried >the following remove-Operations: > >DefaultMutableTreeNode TreeNode= >(DefaultMutableTreeNode)path.getLastPathComponent(); >DefaultMutableTreeNode parentTreeNode= >(DefaultMutableTreeNode)path.getParentPath().getLastPathComponent(); > > // neither > parentTreeNode.remove(index); //with index represents treeNode > // nor > treeNode.removeFromParent(); > // nor > parentTreeNode.remove(treeNode); > // did remove anything > >All these remove-methods do not any modification to the JTree-Object, it >doesn't change its structure and the nodes to remove remain at their >places. >Those methods don't return a value so that I could get aware of a >fault-case. >Could anyone explain me what is the mistake ? > >-- > > > >-Stephan Grimm- > ><Stephan.Grimm@mgm-edv.de> ><grst0018@fh-karlsruhe.de> > >GERMANY > >
Technical Details
Message-ID:
<7i38or$ind7@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<37427B5A.B85EEA55@mgm-edv.de>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,f5bb01ac39cf223f X-Google-Attributes: gid111d45,public From: "Sjaak Wolfert" <sjaak.wolfert@users.info.wau.nl> Subject: Re: removing a node from a JTree Date: 1999/05/21 Message-ID: <7i38or$ind7@forums.borland.com> X-Deja-AN: 480461633 References: <37427B5A.B85EEA55@mgm-edv.de> Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0 Newsgroups: borland.public.jbuilder.java.swing