*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Instance Variable errors for MouseMotionAdapt" Watch "Instance Variable errors for MouseMotionAdapt" New topic
Author

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:
Simple.java:76: ';' expected
Class mouseDragListener extends MouseMotionAdapter
^
Simple.java:57: cannot resolve symbol
symbol : class mouseDragListener
location: class Simple
mouseDragListener myListener = new mouseDragListener(this);
^
Simple.java:57: cannot resolve symbol
symbol : class mouseDragListener
location: class Simple
mouseDragListener myListener = new mouseDragListener(this);
^
3 errors
Finished

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


flodin
Cindy Glass
"The Hood"
Sheriff

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".
this.addMouseMotionAdapter(myListener);

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: http://aspose.com/file-tools
 
subject: Instance Variable errors for MouseMotionAdapt
 
Similar Threads
Java grid colouring in game
ActionListener -- where to put anonymous inner class?
Button not appearing and drawString issue
ActionListener and Event
addActionListener problem