aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes addMouseMotionListener  error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "addMouseMotionListener  error" Watch "addMouseMotionListener  error" New topic
Author

addMouseMotionListener error

Derek Boring
Ranch Hand

Joined: Aug 15, 2006
Posts: 63
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 ]

Life is 10% what happens and 90% how you react to it.
Attitude is everything.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

"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.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Manuel Moons
Ranch Hand

Joined: Mar 05, 2002
Posts: 229
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

Joined: Aug 15, 2006
Posts: 63
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 ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Aug 15, 2006
Posts: 63
Thanks, that helped.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: addMouseMotionListener error