• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What does (this) and ActionEvent e mean?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public class lopotop extends JFrame implements ActionListener {

button.addActionListener(this);

public void actionPerformed(ActionEvent e) {

//something happens

}

}

I have come across this a number of times and have simply memorised how it is written but I have very little (if any) understanding of what is actually going on, something I find hugely frustrating. What do we mean when we pass (this) to the parameters? Again when we pass (ActionEvent e) what do we mean?
And now i basically want to make my own actionlistner to understand the working (don't want to use java built in classes or libraries) some one please guide me how i can do that how many classes should i make , what method use in them?

I have tried reading on this matter and have heard talk of overriding methods and other seemingly mind boggling terms but I have not fully grasped this. I am not content simply writing things I do not understand.

I would appreciate a link to a helpful resource that could help me in this regard or, better yet, if someone who understands this spares a moment to explain this as though they were speaking to a rather dull 15year old

Many thanks in advance for your help.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> What do we mean when we pass (this) to the parameters?

read the apidocs.

button.addActionListener(this);

from the apidocs what is the argument required?
how is it provided?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you gone through the tutorial about Passing Information to a Method or a Constructor?
 
numan ahmad
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have read the apidoc.......
may you please tell me how i can make my own actionlistner please please guide me ?
what classes should i make and what methods wrote in them ?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
start by searching this forum for
addActionListener

read/study the sample code you find
 
reply
    Bookmark Topic Watch Topic
  • New Topic