The Artima Developer Community
Sponsored Link

Java Answers Forum
JTree

1 reply on 1 page. Most recent reply: May 2, 2002 10:37 PM by Vikram.G.S.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
sarvesh

Posts: 8
Nickname: shasija
Registered: Mar, 2002

JTree Posted: May 1, 2002 9:20 PM
Reply to this message Reply
Advertisement
how to dynamically add and delete nodes with JTree.


Vikram.G.S.

Posts: 16
Nickname: vidhi
Registered: Apr, 2002

Re: JTree Posted: May 2, 2002 10:37 PM
Reply to this message Reply
Hi shasija,

We are in same ship. All you have to do is :-

1. Set the TreeModel as DefaultTreemodel(refer JAVA Documentation).
2. get the node(DefaultMutableTreeNode) where u want
delete/add Nodes.
3. in case of adding a node create a new
node(DefaultMutableTreeNode) and add it the selected node.
eg: treeModel.insertNodeInto(new DefaultMutableTreeNode("Child Node"),dmtn,i);
where dmtn is seleted node and i is index of dmtn.
4. delete is made very easy!!!
eg: treeModel.removeNodeFromParent(dmtn);
where treeModel is a object of DefaultTreeModel.

Hope this will help you. in case any problem please inform at : vs_shastry@sify.com

Flat View: This topic has 1 reply on 1 page
Topic: Read input Previous Topic   Next Topic Topic: FileBrowser in Webpage

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use