Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

get event name????

Thread view: 
sight - 04 Feb 2006 00:57 GMT
I have component X that writes xml and gets name and value from components
Y,Z.

since cmponents Y,Z are the same but with idfferent name when i try to catch
their name with source

evt.getSource().getClass().getCanonicalName();

I get the same name.

How do i get the name of every component?
Ian Shef - 06 Feb 2006 19:08 GMT
> I have component X that writes xml and gets name and value from
> components Y,Z.
[quoted text clipped - 7 lines]
>
> How do i get the name of every component?

I think that by "component" you mean "instance of an object".  
I think that by "name" you mean "an object's unique identifier".
If this is what you meant, I think that you are out of luck.  In Java,
objects don't have unique identifiers unless they are designed and
implemented that way.

Sometimes, hashCode() and toString() are of some use, but they are NOT
guaranteed to be unique.

You may want to rethink what you are trying to accomplish, and how you are
trying to accomplish it.

On the other hand, your object X is certainly entitled to keep its own list
of objects (say, a java.util.Hashtable) and to provide its own "name" for
each new instance as it is encountered.

Signature

Ian Shef     805/F6      *    These are my personal opinions    
Raytheon Company         *    and not those of my employer.
PO Box 11337             *
Tucson, AZ 85734-1337    *



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.