• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your help. That resolved the problem.
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic