This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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).]
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.