Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

is JApplet an instance of ActionListner according to this code?

 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Anil Deshpande
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 3213
30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well before I could you had replied sir. Don't take any offense. Some times just things happen
 
Life just hasn't been the same since the volcano erupted and now the air is full of tiny ads.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic