• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

method not abstract

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to create an applet with drop-down lists. when i compile the program the following error message appears '. . .is not abstract and doesnt overide abstract method actionPerformed. . . Here is my code . . . .help please




[Edit - added code tags - MB]
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class implements the ActionListener but the abstract method actionPerformed() is not implemented. Check your method signature.
 
bothwell muyambo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am very new to java and would want some more clarification on the implementation part and avoiding this error message. thank you
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John's just pointed you in the right direction.

ActionListener is an interface. Any (non-abstract) class implementing an interface must provide an implementation of every method in the interface. ActionListener contains a method "actionPerformed", whereas you have implemented "actionPerfomed". Just a small spelling mistake, but these things matter.

Incidentally, you have other problems as well. Never use == to check for String equality, use the equals() method instead.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you implement an interface you have to either implement the methods or mark the methods abstract. In your code you have actually tried to implement the method actionPerformed(). But the name of the method is incorrect. You have missed a 'r'.
 
bothwell muyambo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a big thank you to john and mathew.The problem has been fixed thank you
 
Saloon Keeper
Posts: 6588
160
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a very useful bit of advice: learn to use @Override annotations, whenever you override or implement methods. Big timesaver for exactly the kind of mistake you made here!

http://download.oracle.com/javase/tutorial/java/javaOO/annotations.html
 
bothwell muyambo
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim. I am on it now. . .
 
Greenhorn
Posts: 1
Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mathew that was of great help
 
Marshal
Posts: 70219
282
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch

I presume you noticed the dubious design, using addActionListener(this)?
 
Ranch Hand
Posts: 33
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah I've already encountered this program before. My DavidApplet class program worked well though the design is clumsy because I did not create any layout manager.
 
Legend has it that if you rub the right tiny ad, a genie comes out.
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
    Bookmark Topic Watch Topic
  • New Topic