Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Expanding a Specific Node in JTree

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ranchers,

i stuck up with a problem of tree expanding.

i have one tree
root
+ one
+subone
- 1 // leaf node
- 2 // leaf node
+two
+subtwo
- 3 // leaf node
- 4 // leaf node
+three
+subthree
- 5 // leaf node
- 6 // leaf node


My requirement is,
i have to expand the parent of a leaf node in the tree.


Suppose if I pass object of �6�, the tree should expand
subthree� node.


i have tried in several ways to expand the tree
1) expandRow(int) -- expanding the immidiate childes of root only
2) expandPath(TreePath) -- I can't get path of a node. because mutable node have getPath() method, but it returns array of TreeNode[] not a TreePath.

Please help me.

Thanks in advance.
Sasikala.
[ April 19, 2005: Message edited by: sasi kala ]
 
sasi kala
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

thanks for the reply. i understand the way how tree works and done some coding to find the solution.

What i understand is "to expand a specific node in the tree, we need to expand all its parent nodes". My problem is, i have object of the node which has to be expanded in hand. and i don't know ancestors of that node.

what i observed in JTree is,
1) we have to store all nodes of a tree in some where (like Map), becasue to search any node the JTree needs only that node object (not even new node object with the same data).

2) row numbers of tree nodes are not static. When we pass a row number to "expandRow(row)" method, suppose n, the tree will expand nth visible node from the root.


i solve my problem like below


And finally i came out of the tree expanding problem.
[ April 27, 2005: Message edited by: sasi kala ]
 
I suggest huckleberry pie. But the only thing on the gluten free menu is this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic