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?
Rhino - 04 Feb 2006 05:11 GMT
>I have component X that writes xml and gets name and value from components
> Y,Z.
[quoted text clipped - 8 lines]
>
> How do i get the name of every component?

Your subject line clashes with your question: the subject line asks about
event names but your question asks about component names. Since events don't
have names, I'll assume you mean component names....

This may not be the _only_ way or the best way but many GUI components have
methods so that you can assign them a name of your own choosing. Therefore,
if you have three JPanels in a GUI, you can give them each a unique name,
like Alpha, Beta, and Gamma. Then, you can query the name with another
method.

I just checked the API and everything that descends from java.awt.Component
has access to the setName() and getName() methods of the Component class.
That should cover you for most GUI components.

Non-GUI components may have similar methods; check the API.

--
Rhino


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



©2009 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.