Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JTree - multiple root nodes possible?

640 views
Skip to first unread message

Mark Hennessy

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
Is it possible to display multiple root nodes in a JTree? I tried:

jTree1.setRootVisible(false);

but this means that no items are visible at all! (i.e. the children off the
root node are not made visible)

What I don't understand is that Borland wrote JBuilder 2 from Java, so how
did they get they trees to have multiple views?

Mark Hennessy
IT Director
WinVista Corp

George Lawrence

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
You're on the right track. The way to do this is setRootVisible(false); and
add more children to the hidden root. If they're not showing up, try making
sure that the hidden root is expanded and that you fire the right
notification when each child it added.

-- George


Mark Hennessy wrote in message <6ubor9$jpc$1...@news.lauderdale.net>...

rany

unread,
Sep 29, 1998, 3:00:00 AM9/29/98
to George Lawrence
Hi,

I agree with George about part of the suggestion ... you should use
root which is unvisible and multiple childs ... but I would not
suggest you to try using the notifications by yourself ...
Beware ... the methods are there for the UI components
so unless you rewrite the UI components ... or extends a
particular Look&Feel do not do this.
However, you should insert, remove and change nodes only
through the model (if you use the default model, you can get
it by the getModel() method ... which is there for you !), since
adding not through the model will not update the visible
nodes structures ....

which means, that if you want to insert a node, use the
insertNodeInto through the TreeModel, rather than using
the insert() method .....

Yours,

Rani

0 new messages