Article View: borland.public.jbuilder.java.swing
Article #8273Re: JTree
From: John McGrath TeamB
Date: Wed, 11 Oct 2000 00:00
Date: Wed, 11 Oct 2000 00:00
27 lines
1525 bytes
1525 bytes
On Wed, 11 Oct 2000 01:53:29 -0000, Scott Yaung wrote:
> Here I want to use a tree to display a colmpany tree
> But when I meet some people with the same name
> When I click on the Item ,the getPath return the same
> result ,so what I can do to get which is clicked in fact ?
I am not certain if there is an easy way to deal with identical objects
in a JTree, but I have heard of others running into it. it seems that
somewhere in the process of creating a path, objects are compared for
equality.
The reason I have never run into it is I seldom use a String as the
object added to the tree. Instead, I will add an object (e.g. Person),
and then have the Person.toString() method return the text to be
displayed in the tree. Assuming two Person objects do not test as
equal(), you should not have a problem, even if the toString() method
returns the same string.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<MPG.144e0344d9fdd272989c03@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8rvpob$s96@bornews.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,ca251d41f0acf873 X-Google-Attributes: gid111d45,public From: John McGrath [TeamB] <ng-b@JPMcGrath.net> Subject: Re: JTree Date: 2000/10/11 Message-ID: <MPG.144e0344d9fdd272989c03@forums.borland.com> X-Deja-AN: 680080653 References: <8rvpob$s96@bornews.borland.com> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing