• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[newbie] Syntax error on token(s), misplaced construct(s)

 
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In this snippet I think I declared textArea before so why am I getting a syntax error?





Output:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
ActionListener cannot be resolved to a type

at homenetwork.bkr.training.TextComponentFrame.<init>(TextComponentFrame.java:35)
at homenetwork.bkr.training.TextComponentTest$1.run(TextComponentTest.java:14)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


NOTE: The tags don't seem to work for bold.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please copy and paste the exact error message that you get, that makes it much easier to help you with this.

NOTE: The tags don't seem to work for bold.


No, ubb tags do not work inside a code block.
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aha, I see you edited your post.

ActionListener is in the package java.awt.event, and you're not importing that in your source file. Add this at the top of your source file:

Note that import java.awt.*; does not import everything in package java.awt.event - Java has no subpackages.

The error you get is a little strange, it indicates that you probably have old *.class files lying around. Try deleting them and recompiling everything.
 
Jon Camilleri
Ranch Hand
Posts: 664
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesper Young wrote:Please copy and paste the exact error message that you get, that makes it much easier to help you with this.

NOTE: The tags don't seem to work for bold.


No, ubb tags do not work inside a code block.



lol...I had a missing import, now it's working thanks anyway
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jon, you're getting quote some "Unresolved compilation problem" runtime errors (also in other threads). That tells me you are using an IDE (Eclipse, Netbeans, etc) to run your code. I suggest you check the IDE's compiler errors before trying to run. Those will tell you, more or less, what's wrong. Don't run your code until all errors have been resolved.

In your case, the error should be something like "ActionEvent cannot be resolved to a type". And Jesper told you the reason (although he mentioned the wrong class).
 
reply
    Bookmark Topic Watch Topic
  • New Topic