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

    #1
    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){

    }
    }
    }
     
  2. macrumors newbie

    #2
    Strange

    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

    SilentPanda

    #3
    Glad it worked out for you. In the future (in this forum and others) try to use the
    Code:
     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");
         }
    }
     
  4. macrumors newbie

    #4
    ooooo
    Code:
     tags[/b]
    
    aahhhh, ok, srry, kind of a newbie to the forum thing.
     

Share This Page