import java.applet.Applet;
import javax.swing.*;
import java.awt.*;

public class Colors4 extends JApplet {

    /**
     * Initializes the applet.  You never need to call this directly; it is
     * called automatically by the system once the applet is created.
     */
    public void init() {
	Container pane = getContentPane();
	for (int i=0; i<=10; i++)
	{
	    int grayLevel = (int) (255 * ((double) i / 10));
	    JButton button = new JButton("Gray" + i);
	    Color myGray = new Color(grayLevel, grayLevel, grayLevel);
	    button.setForeground(Color.red);
	    button.setBackground(myGray);
	    pane.setLayout(new GridLayout(11, 1));
	    pane.add(button);
	}
	setSize(300, 300);
    }

}
