File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method not abstract

 
bothwell muyambo
Greenhorn
Posts: 8
  • 0
  • 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]
 
John Jai
Rancher
Posts: 1776
  • 0
  • 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
  • 0
  • 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
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • 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
  • 0
  • 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
  • 0
  • 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
 
Tim Moores
Bartender
Pie
Posts: 2498
10
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Tim. I am on it now. . .
 
Gitch joseph
Greenhorn
Posts: 1
Fedora
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mathew that was of great help
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 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)?
 
Ryan Daguman
Ranch Hand
Posts: 33
Java
  • 0
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic