import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;

public class appl extends Applet
{
	double rand(double a,double b) {return a+Math.random()*(b-a);}
	int rnd(int a,int b) {return (int)Math.floor(rand(a,b));}

	int xres,yres; WritableRaster screen;

	class NullObserver implements ImageObserver
	{
		public boolean imageUpdate(Image img,int infoflags,int x,int y,int width,int height) {return false;}
	} NullObserver observer;

	class DebugCursor
	{
		int x,y;
		public void reset() {x=y=0;}
		public void write(String s) {g.DrawString(s,x,y); y+=15;}
	} DebugCursor debug;

	public void init()
	{
		xres=getWidth(); yres=getHeight();
		Point origin=new Point(0,0);
		screen.createPackedRaster(DataBuffer.TYPE_INT,xres,yres,3,8,origin);
		debug.reset();
	}

	public void paint(Graphics g)
	{
		/*g.drawString("Hello world!",rnd(0,xres),rnd(0,yres));
		Rectangle r=g.getClipBounds();
		g.drawRect(r.x,r.y,r.width,r.height);*/

		try {
		ColorModel cm=new DirectColorModel(24,0xFF0000,0x00FF00,0x0000FF);
		try {
		Image i=new BufferedImage(cm,screen,false,new java.util.Hashtable());
		try {
		g.drawImage(i,0,0,observer);
		} finally debug.write("g.drawImage failed");
		} finally debug.write("new BufferedImage failed");
		} finally debug.write("new DirectColorModel failed");
	}
}

