Currently when you construct a JTree, it is a
pyramid tree (root on top, branch nodes on bottom).
Is possible make JTree upside down pyramid tree (root
on bottom, branch nodes on top)?
Thanks!
Sundar - 22 Feb 2007 08:46 GMT
> Currently when you construct a JTree, it is a
> pyramid tree (root on top, branch nodes on bottom).
> Is possible make JTree upside down pyramid tree (root
> on bottom, branch nodes on top)?
>
> Thanks!
I dont think its possible with jTree. I never came across such method/
setting in jTree. Here is the reference:
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTree.html
-Sundar
http://heysundar.blogspot.com
Rogan Dawes - 22 Feb 2007 09:58 GMT
> Currently when you construct a JTree, it is a
> pyramid tree (root on top, branch nodes on bottom).
> Is possible make JTree upside down pyramid tree (root
> on bottom, branch nodes on top)?
>
> Thanks!
You would need to do some custom coding, but it probably wouldn't be
*that* difficult. I would look at the drawing code (paintComponent?),
and see how it does its calculations.
Then, rather than starting from an origin of (0,0), and adding offsets
to figure out where to render nodes, start by calculating the height of
your tree, then use that height and subtract offsets to figure out where
to paint the nodes.
Regards,
Rogan