Java Tutorial

 
 
 
 
/* <applet code=\"BlinkRect\" height=200 width=300> </applet> */

import java.applet.*;
import java.awt.*;

public class BlinkRect extends Applet 
{
       Color colors[] = { Color.cyan, Color.blue, Color.red, Color.green, Color.yellow,
                                  Color.white, Color.black, Color.orange, Color.pink, Color.magenta};
       Dimension d = getSize();

        public void paint(Graphics g){           
            g.fillRect(10,20,150,150);
            for(int i=0;i<colors.length;i++)
            {
                 g.setColor(colors[i]);
                if (i==colors.length-1)
                 {
                      i=0;
                 }
                 repaint();
            }
        }
}

 
 
Didn't find what you were looking for? Find more on An applet program that display blinking rectangle