This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes is JApplet an instance of ActionListner according to this code? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "is JApplet an instance of ActionListner according to this code? " Watch "is JApplet an instance of ActionListner according to this code? " New topic
Author

is JApplet an instance of ActionListner according to this code?

Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
This is a code which demonstrates the use of JRadioButton



At line number 35,39 and 43, they write a code
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);

My class itself give the implementation of actionPerformed() method

My Problem with this code is how come we can write addActionListener(this) when addActionListener() takes ActionListener as the argument. Does this code mean My class implements ActionListener
by overrriding actionPerformed method(). How did my class became a ActionListener even though i have not declared my class as such.

Please explain?


Anil Deshpande
SCJP 1.5, SCWCD 1.5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35252
    
    7
Does this code mean My class implements ActionListener by overrriding actionPerformed method.

Sort of. It becomes an ActionListener by having an actionPerformed method AND by declaring that it implements the ActionListener interface.

How did my class became a ActionListener even though i have not declared my class as such.

Yes, you have - look at line 11.


Android appsImageJ pluginsJava web charts
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
Yeah, really silly query. Just in hurry I didn't see the code at line 11. Any way thanks a lot. I realized what I did just after I posted the query
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 1791
    
    2
I realized what I did just after I posted the query


Then why didn't you reply to the posting stating you solved the problem, so we don't waste time answering a question that has already been answered. That kind of behaviour will NOT get you help in the future.
Anil Deshpande
Ranch Hand

Joined: Jan 13, 2008
Posts: 117
Well before I could you had replied sir. Don't take any offense. Some times just things happen
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: is JApplet an instance of ActionListner according to this code?
 
Similar Threads
Accessing JRadioButton from another class
problems w/ JCheckBox's and TableModel
Problem with JRadioButton
applets..audio sound
tictactoe help