Java Code
import java.awt.*;
import javax.swing.*;
public class Stripes extends JApplet
{
public void paint( Graphics g )
{
int stripes = 0;
int width = 30;
int height = this.getHeight( );
int appletWidth = this.getWidth( );
for (int x=0; x < appletWidth; x+=width)
{
if (stripes%2 == 0)
{
g.setColor(Color.RED);
}
else
{
g.setColor(Color.CYAN);
}
g.fillRect(x, 0, width, height);
stripes = stripes + 1;
} // end while loop
} // end paint method
}
Back to Code Examples
©2006-
by E.S.Boese. All Rights Reserved