Subject: JavaDraw 2.0.1 Java code

From: [email-masked]
Date: 12 Feb 1999 23:59:12 GMT

import java.awt.*;
import java.io.*;
import java.net.*;

// JavaDraw 2.0.1 file, by Vincent Zimmermann
// Email : [email-masked]
// Web   : http://www.nctech.fr/Zimmermann

// Save this text as MyDrawing.java
// then compile with the command : javac MyDrawing.java
// (you have to install the sun JDK before, http://www.javasoft.com)
// Actually, create an HTML file with the APPLET tag like this :
// <HTML>
// <BODY>
// <H2>A JavaDraw drawing :</H2>
// <APPLET CODE="MyDrawing.class" WIDTH="400" HEIGHT="300">
// </BODY>
// </HTML>

public class MyDrawing extends java.applet.Applet
{
	// Usefull fields.
	Polygon polygon = null;
	Image tmpImage;
	URL fileURL;
	MediaTracker tracker = new MediaTracker(this);
	Toolkit tk = null;

	public static void main(String args[])
	{
		MyDrawing myDrawing = new MyDrawing();
		myDrawing.init();
		myDrawing.start();

		Frame frame = new Frame("JavaDraw drawing");
		frame.add("Center", myDrawing);
		frame.validate();
		frame.resize(400, 300);
		frame.show();
	}

	public void init()
	{
		setBackground(new Color(46, 119, 165));
		tk = Toolkit.getDefaultToolkit();
	}

	public void paint(Graphics g)
	{
		g.setColor(new Color(255, 255, 255));
		g.fillArc(216, 50, 32, 81, 0, 90);
		g.setColor(new Color(0, 0, 0));
		g.drawArc(216, 50, 32, 81, 0, 90);
		g.setColor(new Color(255, 255, 255));
		g.fillRect(209, 71, 204, 185);
		g.setColor(new Color(0, 0, 0));
		g.drawRect(209, 71, 204, 185);
		g.drawLine(209, 71, 413, 256);
		g.drawLine(209, 256, 413, 71);
		g.setColor(new Color(0, 0, 0));
		g.fillOval(315, 170, 1, 1);
		// Paint an image. URL have to be accessible.
		try
		{
			fileURL = new URL("");
			tmpImage = tk.getImage(fileURL);
			tracker.addImage(tmpImage, 0);
			tracker.waitForAll();

			if (tmpImage != null);
			{
			}
		}
		catch (MalformedURLException e)
		{ System.err.println("Error : bad URL "); }
		catch (InterruptedException e)
		{ System.err.println("Error : interrupted MediaTracker "); }
		catch (Exception e)
		{ System.err.println("Error !"); }

		g.setColor(new Color(255, 255, 255));
		g.fillRect(41, 101, 51, 53);
		g.setColor(new Color(0, 0, 0));
		g.drawRect(41, 101, 51, 53);
		g.setColor(new Color(255, 255, 255));
		polygon = new Polygon();
		polygon.addPoint(530, 111);
		polygon.addPoint(541, 134);
		polygon.addPoint(578, 134);
		polygon.addPoint(548, 149);
		polygon.addPoint(559, 172);
		polygon.addPoint(530, 157);
		polygon.addPoint(500, 172);
		polygon.addPoint(511, 149);
		polygon.addPoint(481, 134);
		polygon.addPoint(518, 134);
		polygon.addPoint(530, 111);
		g.fillPolygon(polygon);
		g.setColor(new Color(0, 0, 0));
		g.drawLine(530, 111, 541, 134);
		g.fillOval(530, 111, 0, 0);
		g.drawLine(541, 134, 578, 134);
		g.fillOval(541, 134, 0, 0);
		g.drawLine(578, 134, 548, 149);
		g.fillOval(578, 134, 0, 0);
		g.drawLine(548, 149, 559, 172);
		g.fillOval(548, 149, 0, 0);
		g.drawLine(559, 172, 530, 157);
		g.fillOval(559, 172, 0, 0);
		g.drawLine(530, 157, 500, 172);
		g.fillOval(530, 157, 0, 0);
		g.drawLine(500, 172, 511, 149);
		g.fillOval(500, 172, 0, 0);
		g.drawLine(511, 149, 481, 134);
		g.fillOval(511, 149, 0, 0);
		g.drawLine(481, 134, 518, 134);
		g.fillOval(481, 134, 0, 0);
		g.drawLine(518, 134, 530, 111);
		g.fillOval(518, 134, 0, 0);
		g.setColor(new Color(159, 113, 86));
		g.fillRect(120, 79, 112, 77);
		g.setColor(new Color(0, 0, 220));
		g.drawRect(120, 79, 112, 77);
		g.setColor(new Color(255, 255, 255));
		polygon = new Polygon();
		polygon.addPoint(406, 58);
		polygon.addPoint(438, 73);
		polygon.addPoint(438, 105);
		polygon.addPoint(406, 121);
		polygon.addPoint(374, 105);
		polygon.addPoint(374, 73);
		polygon.addPoint(406, 58);
		g.fillPolygon(polygon);
		g.setColor(new Color(0, 0, 0));
		g.drawLine(406, 58, 438, 73);
		g.fillOval(406, 58, 0, 0);
		g.drawLine(438, 73, 438, 105);
		g.fillOval(438, 73, 0, 0);
		g.drawLine(438, 105, 406, 121);
		g.fillOval(438, 105, 0, 0);
		g.drawLine(406, 121, 374, 105);
		g.fillOval(406, 121, 0, 0);
		g.drawLine(374, 105, 374, 73);
		g.fillOval(374, 105, 0, 0);
		g.drawLine(374, 73, 406, 58);
		g.fillOval(374, 73, 0, 0);
		g.setColor(new Color(255, 255, 255));
		g.fillRoundRect(230, 33, 30, 53, 30, 30);
		g.setColor(new Color(0, 0, 0));
		g.drawRoundRect(230, 33, 30, 53, 30, 30);
	}
}

// That's all folk !  ;-)
// Fri Feb 12 18:59:11 EST 1999
// Generated by JavaDraw, version 2.0.1