Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > removing node from the JTree

Reply
Thread Tools

removing node from the JTree

 
 
Narayanan Kaleeswaram
Guest
Posts: n/a
 
      01-15-2004
Hello,
What I will do for removing and loading another node in the same
row to the JTree.Adding node to tree is as follows(in ActivateEvent of
the InternalFrame).
-------------
dmtnFun=new DefaultMutableTreeNode(filename);//dmtnFun,
DefaultMutableTreeNode
//filename is String
funTree=new JTree(dmtnFun);//JTree object
panFun.add(funTree); panFun is a JLabel
for(int i=0;i<10;1++)
dmtnFun.add(new DefaultMutableTreeNode(fun[i])); //fun is a String
array
((DefaultTreeModel)funTree.getModel()).reload(dmtn Fun);
would like to remove this perticlar node(dmtnFun) from the tree in
DeactivateEvent of the InternalFrame and add new node(dmtnFun) with
the above code.
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      01-15-2004
Narayanan Kaleeswaram wrote:
> Hello,
> What I will do for removing and loading another node in the same
> row to the JTree.Adding node to tree is as follows(in ActivateEvent of
> the InternalFrame).
> -------------
> dmtnFun=new DefaultMutableTreeNode(filename);//dmtnFun,
> DefaultMutableTreeNode
> //filename is String
> funTree=new JTree(dmtnFun);//JTree object
> panFun.add(funTree); panFun is a JLabel
> for(int i=0;i<10;1++)
> dmtnFun.add(new DefaultMutableTreeNode(fun[i])); //fun is a String
> array
> ((DefaultTreeModel)funTree.getModel()).reload(dmtn Fun);
> would like to remove this perticlar node(dmtnFun) from the tree in
> DeactivateEvent of the InternalFrame and add new node(dmtnFun) with
> the above code.



Provide real code, not this random collection of lines.

What I can guess from his mess is:

You are not changing the data via the TreeModel, but you somehow
mess with the JTree and the individual nodes. Don't do this.
Also, do not use reload(). The TreeModel methods for inserting and
removing nodes are supposed to fire the necessary events to the
JTree. If you use a DefaultTreeModel, this firing is already
implemented. If you have your own implementaion of TreeModel, you
are supposed to implement this handling.

Get a good book about Swing, or at least read the Sun GUI tutorial,
and the Swing architecture article in Sun's TCS article collection.

/Thomas



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JTree Selection lost when JTree looses focus jumpz Java 3 11-12-2007 03:55 PM
removing a node from a node-set jonny@drugphish.ch XML 0 12-02-2006 11:46 AM
xsl variable $node/text() but $node can non-node-set help! Tjerk Wolterink XML 2 08-24-2006 03:28 AM
How to set the node indent property between the parent node and the leaf node viveknatani@gmail.com ASP .Net 0 02-13-2006 07:11 PM
[JTree] Adding a leaf to a node Alexandre Jaquet Java 0 11-08-2003 06:30 PM



Advertisments