FileDocCategorySizeDatePackage
TerribleFlicker.javaAPI DocExample926Wed Mar 26 01:23:32 GMT 1997None

TerribleFlicker

public class TerribleFlicker extends Applet implements MouseMotionListener

Fields Summary
int
grid
int
currentX
int
currentY
Image
img
int
imgWidth
int
imgHeight
Constructors Summary
Methods Summary
public voidinit()


	   
		img = getImage( getClass().getResource(getParameter("img")) );
		addMouseMotionListener( this );
	
public voidmouseDragged(java.awt.event.MouseEvent e)

		currentX = e.getX(); currentY = e.getY();
		repaint();
	
public voidmouseMoved(java.awt.event.MouseEvent e)

 
public voidpaint(java.awt.Graphics g)

		int w = getSize().width/grid;
		int h = getSize().height/grid;
		boolean black = false;
		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 );
			}
		g.drawImage( img, currentX, currentY, imgWidth, imgHeight, this );