FileDocCategorySizeDatePackage
squares.javaAPI DocExample1028Tue Aug 15 13:25:24 BST 2000None

squares

public class squares extends Applet

Fields Summary
Dimension
appletSize
int
xCoord
int
yCoord
final int
width
final int
height
int
xCount
int
yCount
Constructors Summary
Methods Summary
public voidpaint(java.awt.Graphics g)

	
	   
	
		appletSize = this.getSize();		// get the dimensions of this applet
		xCoord     = 0;						// start in the top left corner
		yCoord     = 0;
		yCount     = 1;
													// loop over the applet height
		do
		{
			if (yCount % 2 == 0)
			{
				xCount      = 1;
			}
			else
			{
				xCount = 0;
			}
			xCoord = 0;
													// loop over the applet width
			do
			{
				if (xCount % 2 == 0)
				{
					g.setColor(Color.white);
				}
				else
				{
					g.setColor(Color.black);
				}
				g.fillRect(xCoord, yCoord, width, height);
				xCoord = xCoord + width;
				xCount = xCount + 1;
			} while (xCoord < appletSize.width);
			
			yCount = yCount + 1;
			yCoord = yCoord + height;
		} while (yCoord < appletSize.height);