"sight" <bl***@bljak.spam> wrote in news:ds**********@bagan.srce.hr:
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?
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.
--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *