• Post Reply Bookmark Topic Watch Topic
  • New Topic

package2.Class2 is not abstract and does not override abstract method actionPerformed(ja  RSS feed

 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting the following error on line #7 of the code that is pasted in below. Can anyone explain what I need to do to fix this error. Thank you.

checkboxtest2.CheckBoxTest2 is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bud Tippins wrote:...checkboxtest2.CheckBoxTest2 is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener...

Your class, CheckBoxTest2, is declared to implement the interface, ActionListener.

ActionListener has an abstract method called actionPerformed. You need to override this method by providing a method body (what you want to happen when the action is performed).

(If you do not ovrride that method, then your class CheckBoxTest2 is not complete, and should be declared abstract.)
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that I look at your code, it looks like you're mixing ItemListener and ActionListener. You have a method, itemStateChanged(ActionEvent event). It looks like that's the method you intended to name actionPerformed.

If you implement the interface, ItemListener, then you override the method, itemStateChanged(ItemEvent e).

If you implement the interface, ActionListener, then you override the method, actionPerformed(ActionEvent e).
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding @Override (called an annotation) immediately before the method as in the following code. Doing so will give you an error when you think you are overriding a method but actually are not because you have not specified the interface on your implements line or have the method signature wrong.
 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help. That resolved the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!