|
|
|
|
|
|
SolutionDownload ColorTest source code.HTML Interface to Applet<APPLET CODEBASE="/applets/magelang/AWT-Training/classes/" CODE="ColorTest.class" WIDTH=300 HEIGHT=150 ALIGN=CENTER></APPLET> Java Codeimport java.awt.*; public class ColorTest extends java.applet.Applet { public void init() { setLayout(new GridLayout(2,2)); add(new ColorCanvas(Color.black)); add(new ColorCanvas(Color.red)); add(new ColorCanvas(Color.orange)); add(new ColorCanvas(Color.yellow)); } } class ColorCanvas extends Canvas { Color color; public ColorCanvas(Color c) { color = c; } public void paint(Graphics g) { g.setColor(color); g.fillRect(0, 0, size().width, size().height); } } |