Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does (this) and ActionEvent e mean?

 
numan ahmad
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • 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?
 
Darryl Burke
Bartender
Posts: 5126
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
start by searching this forum for
addActionListener

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