🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1571

Re: Updating a Node in a JTree

#1571
From: nobody Thomas Weidenfeller
Date: Thu, 06 Dec 2001 10:10
28 lines
2492 bytes
"Laurent Souriau" <lsouriau@club-internet.fr> writes:
> I want to  add a node who has only one father in my JTree.
> 
> Let s say TOTO (father ) -> TUTU (child)
> 
> but this father is at different places in the Tree.
> When i add TUTU to TOTO, it is added at only one place of my
> JTree. It is never added to the other TOTO in the tree.

You have the same node at two positions in the tree? Then you are in
trouble, because you technically don't have a tree any more. You will
get into all sorts of trouble. And in fact, you can't do that with the
default tree model implementations, since they can have one parent
only.

If you have copies of the same node in the tree, then at least the tree
is fine. Since technically these are different parents (that just have
the same representation on the screen), you will have to add copies of
the child multiple times.

It's not too difficult to design a data structure that does what you
want, and implement a tree model interface on top of it, but you have
to carefully separate your internal data structure, and the structure
which you reveal via the tree model interface. Have a look at the
adapter and bridge design patterns if you want to separate them even
further.

/Thomas
Technical Details
Message-ID: <9ung64$3en$3@newstoo.ericsson.se>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erinews.ericsson.se!newstoo.ericsson.se!not-for-mail
References: <9unf78$u3c$1@s1.read.news.oleane.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,d56134f219bdd00d
X-Google-Attributes: gid1089d0,public
X-Google-Thread: f74b3,d56134f219bdd00d
X-Google-Attributes: gidf74b3,public
X-Google-Thread: 10a146,d56134f219bdd00d
X-Google-Attributes: gid10a146,public
X-Google-Thread: 113ae9,d56134f219bdd00d
X-Google-Attributes: gid113ae9,public
X-Google-ArrivalTime: 2001-12-06 02:33:12 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!newsfeed1.telenordia.se!algonet!uab.ericsson.se!erinews.ericsson.se!newstoo.ericsson.se!not-for-mail
From: nobody@eed.ericsson.invalid@eed.ericsson.se (Thomas Weidenfeller)
Newsgroups: borland.public.jbuilder.java.api,borland.public.jbuilder.java.language,comp.lang.java.help,comp.lang.java.programmer
Subject: Re: Updating a Node in a JTree
Date: 6 Dec 2001 10:10:12 GMT
Organization: Ericsson Eurolab Deutschland GmbH, Germany
Lines: 28
Message-ID: <9ung64$3en$3@newstoo.ericsson.se>
References: <9unf78$u3c$1@s1.read.news.oleane.net>
NNTP-Posting-Host: aquis74.eed.ericsson.se
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 1.0b.1