• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

actionPerfomed

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can actionPerfomed method be called directly? also can any user-defined object use addActionListener to get an event listener? Thank you.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
Regards,
Manfred.
 
tom nugent
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Manfred. You answered my questions.
reply
    Bookmark Topic Watch Topic
  • New Topic