• 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

addMouseMotionListener error

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is probably a simple answer that will make me feel retarded, but i'm not seeing the problem. Please help guys!

I have a class I'm writing that extends JPanel. I want the JPanel to produce mouseMove events, but the code following this paragraph produces the error shown below it.



The error is:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Syntax error on token "actMove", VariableDeclaratorId expected after this token

It says the error is on the "actMove" that is in the "addMouseMotionListener" paranthesis.
Anybody know what I could be doing wrong?
[ July 24, 2007: Message edited by: Zero ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Zero",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted.
 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code you are showing us is correct! (supposing that you have an mMoved(MouseEvent me); method)

I am thinking that there is something else in the class file where you got the snippet from that is causing your problem. If you have not located your problem at this time it might be better that you show us an entire class that produces the error (compilation error).
 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First off, my apologies on the name thing.


I still haven't been able to find the problem. I'm posting the class below this. I don't know how much this explanation will help, but maybe the more info I give you guys, the more you can help: I'm making a platform game that uses a string array to store the level. Each cell of the level has an object, and a color, stored in the following format: "object-r.g.b" All the confusing code in the 'paint' event is decoding each cell and drawing it. The other methods are probably self explanatory, but let me know if clarification is needed. By the way, this code is not for the game itself, it's for a component of the level editor. This panel is to be shown inside a JScrollPane.

The bolded text is where the error occurs:


Anybody see anything I didn't?
[ July 25, 2007: Message edited by: Derek Boring ]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't get the error message you do, but it doesn't compile because
addMouseMotionListener(actMove);
needs to be inside a method.

compiles OK when moving all the mouseMotionListener code to the constructor
 
Derek Boring
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, that helped.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic