1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Java MouseListener Help

Discussion in 'Mac Programming' started by Sweetlipsof06, Nov 29, 2007.

  1. macrumors newbie

    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();

    public void mouseDragged(MouseEvent e){

  2. macrumors newbie


    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.
  3. Moderator emeritus


    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) {
    [code]public static void main(String[] args) {
         if (true) {
  4. macrumors newbie

    aahhhh, ok, srry, kind of a newbie to the forum thing.

Share This Page