import java.awt.Color;
import java.awt.GridLayout;
import javax.swing.JApplet;
import javax.swing.JPanel;
public class Colors2 extends JApplet {
public void init() {
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
}
});
}
catch (Exception e) {
System.err.println("createGUI didn't successfully complete");
}
}
private void createGUI() {
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(64, 64));
for (short i = 0; i < 0x100; i += 4) {
for (short j = 0; j < 0x100; j += 4) {
JPanel subpanel = new JPanel();
subpanel.setBackground(new Color(j, 0, i));
panel.add(subpanel);
}
}
getContentPane().add(panel);
}
} |