import java.awt.*;
import java.applet.*;
public class squares extends Applet
{
Dimension appletSize;
int xCoord = 0;
int yCoord = 0;
final int width = 30;
final int height = 30;
public void paint(Graphics g)
{
appletSize = this.getSize(); // get the dimensions of this applet
xCoord = 0; // start in the top left corner
yCoord = 0;
g.setColor(Color.red);
do
{
g.drawRect(xCoord, yCoord, width, height);
xCoord = xCoord + width;
} while (xCoord < appletSize.width);
}
} |