import java.awt.Color;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Panel;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.*;
public class MyTest{
public static void main(String args[]){
Frame w=new Frame();
w.setSize(300,400);
MyPanel mp=new MyPanel();
w.add(mp);
w.addMouseMotionListener(mp);
mp.addMouseMotionListener(mp);
w.setVisible(true);
}
}
class MyPanel extends Panel implements MouseMotionListener{
int x=20;
int y=20;
public void paint(Graphics g){
g.fillOval(x,y,20,20);
}
@Override
public void mouseDragged(MouseEvent arg0){
}
@Override
public void mouseMoved(MouseEvent arg0){
}
public void MouseDragged(MouseEvent arg0){
x=arg0.getX();
y=arg0.getY();
repaint();
}
}