wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes actionPerfomed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "actionPerfomed" Watch "actionPerfomed" New topic


tom nugent
Ranch Hand

Joined: Dec 20, 2000
Posts: 32
Can actionPerfomed method be called directly? also can any user-defined object use addActionListener to get an event listener? Thank you.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Tom,
It depends on how you defined your actionPerformed. If you used an anonymous class you are out of luck. If you just have an actionPerformed method in your class that uses a switch statement or if/then to figure out which source called it then you can go ahead and call it after you create an ActionEvent object containing useful information.
If you used Anonymous classes you will need to perform something like the following.

To use addActionListener, the user-defined object will need to subclass an AWT class that defines it. Otherwise you will need to define it yourself. Your user-defined object will have to be subclass in AWT or you are really wasting your time!
tom nugent
Ranch Hand

Joined: Dec 20, 2000
Posts: 32
Thank you, Manfred. You answered my questions.
I agree. Here's the link: http://aspose.com/file-tools
subject: actionPerfomed
Similar Threads
When to use anonymous class
Performance of Anonymous class
problem with ActionListener of jTextField
Very Confused!!
JTextField ActionListener - user edits vs programmatic edits