PDA

View Full Version : Java MouseListener Help




Sweetlipsof06
Nov 29, 2007, 02:14 AM
I'm having issues with implementing MouseListener and MouseMotionListener, it continues to say that MyMouseMotionListener must implement the inherited abstract method MouseMotionListener.mouseDragged(MouseEvent), but as you can see in my code below, I have, thus leading to my confusion. Any Ideas?


import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class MouseRectangleAnimation extends JApplet{

int x, y;

public void init(){
addMouseMotionListener(new MyMouseMotionListener());
}

public class MyMouseMotionListener implements MouseMotionListener{

public void mouseMoved(MouseEvent e){
x = e.getX();
y = e.getY();
repaint();
}

public void mouseDragged(MouseEvent e){

}
}
}



Sweetlipsof06
Nov 29, 2007, 02:31 PM
Okay, created a new project and the same code worked fine, same settings and everything, don't know why, but it works so I'm happy.

SilentPanda
Nov 29, 2007, 02:41 PM
Glad it worked out for you. In the future (in this forum and others) try to use the tag around your code (or similar on other forums) as it makes the code retain its format thus insuring all your beautiful spacing and tabbing gets preserved. :)

public static void main(String[] args) {
if (true) {
System.out.println("hi");
}
}

[code]public static void main(String[] args) {
if (true) {
System.out.println("hi");
}
}

Sweetlipsof06
Nov 29, 2007, 09:58 PM
aahhhh, ok, srry, kind of a newbie to the forum thing.