import java.awt.*;
import java.awt.event.*;

public class UpdateOverride extends java.applet.Applet 
implements MouseMotionListener{ 

  int grid = 10;
  int currentX, currentY;
  Image img;

  public void init() {
    img = getImage( getCodeBase(), "monaSmall.gif" );
    addMouseMotionListener(this);
  }

  public void mouseDragged( MouseEvent e ) {
    currentX = e.getX();
    currentY = e.getY();
    repaint();
  }
  // Have to override mouseMoved with empty method.
  public void mouseMoved ( MouseEvent e){}

  public void update( Graphics g)
  {
	  paint(g);
  }
  
  public void paint( Graphics g ) {
    int w = getSize().width/grid;
    int h = getSize().height/grid;
    boolean black = false;

    // Draw the checkerboard background
    for ( int y = 0; y <= grid; y++ ) 
      for ( int x = 0; x <= grid; x++ ) {
        g.setColor(  (black = !black) ? Color.black : Color.white );
        g.fillRect( x * w, y * h, w, h );
      }
    // then the image
    g.drawImage( img, currentX, currentY, this );
  }
}

