I just made my first applet. The purpose of it is to show a color map of red horizontally and blue vertically.
It compiles, but it doesn't work on a html page or a browser.
Anyone know what's wrong with it?
|
Code:
|
import java.awt.*;
import javax.swing.*;
class colors extends JApplet {
public void init() {
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);
}
} |