Mouse Motion Listener

mouseDragged
mouseMoved

Application : In first TextArea user perform any MouseMotionAction (Dragged or Moved), simultaneously the action name should appear in the second TextArea along with the location(row and column number).











import java.awt.*;
import java.awt.event.*;
class FrameMouseMotion implements MouseMotionListener
{
    Frame f;
    TextArea ta1, ta2;

    FrameMouseMotion()
    {
        f = new Frame();
        ta1=new TextArea(20,20);
        ta2=new TextArea(20,20);
   
        f.add(ta1);
        f.add(ta2);
       
        f.setLayout(new FlowLayout());
        ta1.addMouseMotionListener(this);

        f.setSize(400,400);
        f.setVisible(true);
    }
    public void mouseDragged(MouseEvent e)
    {
        int x = e.getX();
        int y = e.getY();
        ta2.append("Dragged"+" at "+x+","+y+"\n");
    }
    public void mouseMoved(MouseEvent e)
    {
        int x = e.getX();
        int y = e.getY();
        ta2.append("Moved"+" at "+x+","+y+"\n");
    }
    public static void main(String [] args)
    {
        FrameMouseMotion x = new FrameMouseMotion();
    }
}