What about javax.swing.DefaultMutableTreeNode
This is a purely data model class - ie it is not restricted nor linked
to visual trees


On Fri, Jan 08, 1999 at 05:07:08PM +0530, Karthik Vishwanath wrote:
> HI all,
>       I need to generate a tree structure in my Java app. The size of
> the tree cannot determined until runtime. THe idea i have is to store
the
> tree as an array using the Vector class. Before i start
implementation, i
> want to ask if there is an alternative approach to this?

That solution would work fine, of course.  The alternative is a
`linked tree' structure.  Binary trees are easy (just store each
node's left and right children, and probably the parent).  Trees
with arbitrary numbers of branches are a little more complex.  My
preferred solution is for each node to store parent, first child,
and `sibling', so to enumerate a node's children, you find the
first child then follow it's sibling list.

Unfortunately there isn't a standard tree class in the API, but you
could
implement a class for a tree of arbitrary objects and use that if you
wanted.

Thomas
--
<html>
<head>
<META HTTP-EQUIV="Expires" Name="Expires" CONTENT="Tue, 04 Dec 1997
21:29:02 GMT">
</head>
<body>
<HR>
My ICQ#:8055710<br>
ICQ Status: <img
src="http://online.mirabilis.com/scripts/online.dll?icq=8055710&img=2"><br>

<a href="http://wwp.mirabilis.com/scripts/Search.dll?to=8055710">Add
Me</a><br>
Martin FUZZEY<br>
</body>
</html>

Reply via email to