File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Instance Variable errors for MouseMotionAdapt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instance Variable errors for MouseMotionAdapt" Watch "Instance Variable errors for MouseMotionAdapt" New topic

Instance Variable errors for MouseMotionAdapt

capp luckett
Ranch Hand

Joined: Dec 07, 2000
Posts: 33
If someone could look at this code and let me know why I am getting my compile errors.
I am trying to get a listener variable and instanciate to the applet for mouseDragged. What can I
do to correct it?? I don't understand where to set instance variables up when there are more than 1 adapter/class being used Thanks capp.

Errors: ';' expected
Class mouseDragListener extends MouseMotionAdapter
^ cannot resolve symbol
symbol : class mouseDragListener
location: class Simple
mouseDragListener myListener = new mouseDragListener(this);
^ cannot resolve symbol
symbol : class mouseDragListener
location: class Simple
mouseDragListener myListener = new mouseDragListener(this);
3 errors

[This message has been edited by Cindy Glass (edited October 16, 2001).]

Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521

Class mouseDragListener extends MouseMotionAdapter

You capitalized the word Class, so instead of understanding this as a class declaration the compiler thinks that you are declaring a variable of type Class and calling it mouseDragListener, and that you forgot the semi-colon.
Same for Class buttList - make it lower case.
However you have several other problems;

mouseDragListener myListener = new mouseDragListener(this);

There is no constructor that takes a parameter. Get rid of the "this".

There is no addMouseMotionAdapter method, it should be addMouseMotionListener even if you extend an adapter.
In your constructor for myApp you are passing in a variable called myApp, but when you used it you called it theApp
this.theApp = theApp; //should be
this.theApp = myApp; //??

In the mouseDragListener class you reference the variable theApp several times. This variable was declared in class buttList and is therefore not available to this class. If you want to inherit it, declare it in class Simple instead.
You are also jumping through hoops to use theApp instead of just referencing itself - just get rid of it.

This compiled, but I did not test it.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: Instance Variable errors for MouseMotionAdapt
Similar Threads
addActionListener problem
Java grid colouring in game
ActionListener -- where to put anonymous inner class?
ActionListener and Event
Button not appearing and drawString issue