• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

method not abstract

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a big thank you to john and mathew.The problem has been fixed thank you
 
Saloon Keeper
Posts: 7645
178
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Tim. I am on it now. . .
 
Greenhorn
Posts: 1
Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mathew that was of great help
 
Marshal
Posts: 79974
396
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The City calls upon her steadfast protectors. Now for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic