Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding addactionListener method??

 
aresh babu
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
import java.awt.*;
import java.awt.event.*;
class Shar extends Frame implements ActionListener
{
public Shar(){
Panel p=new Panel();
Button b=new Button();
p.add();
b.addActionListener(this);

//more code here

}
public void actionPerformed(ActionEvent ae)
{
System.out.println(" Hi ");
}
public static void main(Stirng s[])
{
Shar s=new Shar();
}
}



My Doubt is How the control flow calls the actionPerformed() method after b.addActionListener(this); ???


Thanks in Adv
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's called when you press the button, button's UI haves event handler which implements MuoseListener and more which fires this actionPerformed.

And next time use code tags, it's just mouse click away.
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Miiko means Use Code Tags.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic