aspose file tools*
The moose likes Beginning Java and the fly likes method not abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "method not abstract" Watch "method not abstract" New topic
Author

method not abstract

bothwell muyambo
Greenhorn

Joined: Oct 21, 2011
Posts: 8
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
Bartender

Joined: May 31, 2011
Posts: 1776
The class implements the ActionListener but the abstract method actionPerformed() is not implemented. Check your method signature.
bothwell muyambo
Greenhorn

Joined: Oct 21, 2011
Posts: 8
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

Joined: Apr 06, 2010
Posts: 4490
    
    8

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
Bartender

Joined: May 31, 2011
Posts: 1776
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

Joined: Oct 21, 2011
Posts: 8
a big thank you to john and mathew.The problem has been fixed thank you
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Oct 21, 2011
Posts: 8
Thank you Tim. I am on it now. . .
Gitch joseph
Greenhorn

Joined: Jun 07, 2012
Posts: 1

Thanks Mathew that was of great help


GITCH
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
And welcome to the Ranch

I presume you noticed the dubious design, using addActionListener(this)?
Ryan Daguman
Ranch Hand

Joined: Feb 20, 2014
Posts: 33

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.


RyanLD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: method not abstract