JTree & expanding nodes
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   a_a
Posted On:   Friday, March 15, 2002 09:05 AM

Hi I have a Jtree to which I have add TreeExpansion listener only when the user clicks on the parent node,the listener gets the child nodes and inserts it into the tree model now the problem is this tree is drag enabled so the user can drag this parent node without first expanding it I want to dynamically expand the dragged node so that I am able to add all the children to the target How do I do this I tried " Tree.expandPath(path)" this expands the node to the first level but some how it doesnot return the child   More>>


Hi I have a Jtree to which I have add
TreeExpansion listener

only when the user clicks
on the parent node,the listener
gets the child nodes and inserts it into the tree model


now the problem is this tree is drag enabled



so the user can drag this parent node
without first expanding it


I want to dynamically expand the
dragged node so that
I am able to add all the children to
the target




How do I do this




I tried " Tree.expandPath(path)"
this expands the node to the first level

but some how it doesnot return the children



Please help

   <<Less

Re: JTree & expanding nodes

Posted By:   Aparna_Chaturvedi  
Posted On:   Tuesday, March 19, 2002 02:52 AM

U can give the path of selected node in

tree.expandPath(selectednode path)


TreeNode currNode = (TreeNode)JTree.getLastSelectedPathComponent;

tree.expandpath(new TreePath(currNode.getPath())

or u can use

tree.setExpandedState(new TreePath(currNode.getPath()),true);

this will surely work i think

About | Sitemap | Contact