• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
Chrome Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Rob Spoor
Sheriff
Pie
Posts: 20399
47
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • 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).
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic