Newbie simple question

D

Dev_Prog

Hello all,
I started to write the code of the actionPerformed() function as part
of implementing the ActionListener for menu and component events.
- In the case of GUI components, I refer to the component name to
detect the event source.
- In the case of menu-items, I refer to the menu item displayed string
to detect the source.
As an old fashion coder, I wish there was some sort of unique-id
mechanism to detect the event source, and more preferably if that
unique-id is numeric.
My feeling is that such unique-id would be one of the Object class
variables as Object is the abstract of the inheritance tree.
Can anybody throw some ideas of how to receive a unique value inside
the actionPerformed() function from the virtual machine or the OS?
Thanks gurus.
 
C

Christophe Vanfleteren

Dev_Prog said:
Hello all,
I started to write the code of the actionPerformed() function as part
of implementing the ActionListener for menu and component events.
- In the case of GUI components, I refer to the component name to
detect the event source.
- In the case of menu-items, I refer to the menu item displayed string
to detect the source.
As an old fashion coder, I wish there was some sort of unique-id
mechanism to detect the event source, and more preferably if that
unique-id is numeric.
My feeling is that such unique-id would be one of the Object class
variables as Object is the abstract of the inheritance tree.
Can anybody throw some ideas of how to receive a unique value inside
the actionPerformed() function from the virtual machine or the OS?
Thanks gurus.

Use actions to solve these kinds of problems elegantly:

http://java.sun.com/docs/books/tutorial/uiswing/misc/action.html

No need to muck about with unique id's, as with actions, you don't really
care where the action came from, just what you have to do when it is
performed.
 
A

Andrew Thompson

Hello all,
I started to write the code of the actionPerformed() function as part
of implementing the ActionListener for menu and component events.
- In the case of GUI components, I refer to the component name to
detect the event source.
- In the case of menu-items, I refer to the menu item displayed string
to detect the source.
As an old fashion coder, I wish there was some sort of unique-id
mechanism to detect the event source,

You can get the component that fired
the action. How much more unique do
you need it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top