Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

addActionListener problem  RSS feed

 
Sacha Crompton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for all these posts, I'm having another problem now that I changed from JFrame to Applet:

I get this error during compile:
c:\java\calc.java:36: addActionListener(java.awt.event.ActionListener) in java.awt.Button cannot be applied to (calc)
btn1.addActionListener(this);

Thanks
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / AWT / SWT / JFace forum...
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The call to addActionListener will only compile if the class "calc" declares that it implements the ActionListener interface; since it's not compiling, I'm guessing that "calc" doesn't implement this interface.
 
Sacha Crompton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i use:
public class calc extends Applet implements ActionListener{...

I get:
c:\java\calc.java:7: calc should be declared abstract; it does not define actionPerformed(java.awt.event.ActionEvent) in calc
public class calc extends Applet implements ActionListener{
 
Sacha Crompton
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Figured it out, nevermind and thanks for your fast replies.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!