Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Help with this code

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what's wrong with it. It's saying

4 errors found:
File: J:\Java\Java Acces\bookClasses\craps.java [line: 11]
Error: J:\Java\Java Acces\bookClasses\craps.java:11: craps is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
File: J:\Java\Java Acces\bookClasses\craps.java [line: 24]
Error: J:\Java\Java Acces\bookClasses\craps.java:24: cannot find symbol
symbol : class JLabe1
location: class craps
File: J:\Java\Java Acces\bookClasses\craps.java [line: 54]
Error: J:\Java\Java Acces\bookClasses\craps.java:54: cannot find symbol
symbol : variable sumLabel
location: class craps
File: J:\Java\Java Acces\bookClasses\craps.java [line: 55]
Error: J:\Java\Java Acces\bookClasses\craps.java:55: cannot find symbol
symbol : variable sumLabel
location: class craps

And it's weird, because I have ALL of the required packages. I'm fairly new at this, but I really enjoy it. Any help would be greatly appreciated.

Here is the code


 
author
Posts: 23834
140
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You declare a class that is a ActionListener. This requires you to implement the actionPerformed() method. If you look closely, you will see that you didn't implement that method.

Henry
 
Jason Newman
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I do this? I'm REALLY new(ish).
 
Henry Wong
author
Posts: 23834
140
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jason Newman wrote:How would I do this? I'm REALLY new(ish).



Hint: Check your spelling.

Henry
 
Marshal
Posts: 65021
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have methods you are trying to override or implement from interfaces, put the @Override annotation before the method header. Then you will get a "does not override" error if you have spelt it wrongly.
 
Jason Newman
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for all the help, It's great to have a helpful place for Java outside of school. If I get the method working, I'll set the status as 'resolved'. Thank you again for the help!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!