The Applet


The Source Code

/*
	A basic extension of the java.applet.Applet class
 */

import java.awt.*;
import java.applet.*;
import java.awt.Color;

public class ShowArcs extends Applet
{
	public void init()
	{
		// This code is automatically generated by Visual Cafe when you add
		// components to the visual environment. It instantiates and initializes
		// the components. To modify the code, only use code syntax that matches
		// what Visual Cafe can generate, or Visual Cafe may be unable to back
		// parse your Java file into its visual environment.
		//{{INIT_CONTROLS
		setLayout(null);
		setSize(550,400);
		//}}
		System.out.println("Bold = " + Font.BOLD +", Italic = "+ Font.ITALIC +", Plain = " + Font.PLAIN);
	}

	//{{DECLARE_CONTROLS
	//}}

	public void paint(Graphics g) {

	   g.setColor(Color.blue);
	   g.fillRect(10,10,535, 185);
	   g.setColor(Color.white);
	   g.setFont(new Font("SanSerif", 18, Font.PLAIN));
	   g.drawString("The arc is drawn in red, and the method parameters are:", 20, 40);
	   g.drawString("g.drawArc(200, 200, 80, 80, 30, 90)", 25, 55);
	   g.drawString("According to the Java docs:", 20, 80);
	   g.drawString("The center of the arc is the center of the rectangle whose origin is (x, y)", 25, 95);
	   g.drawString("and whose size is specified by the width and height arguments.", 25, 110);
	   g.drawString("The blue rectangle is drawn from the same numbers passed to drawArc:", 20, 135);
	   g.drawString("g.drawRect(200, 200, 80, 80)", 25, 150);
	   g.drawString("The blue dot is the center of the rectangle.", 20, 170);
	   g.setColor(Color.black);
	   g.drawLine(0,200,400,200);
	   g.drawLine(200,185, 200, 400);
	   g.drawString("(200, 200)", 124, 216);
	   g.setColor(Color.red);
	   g.drawArc(200, 200, 80, 80, 30, 90);

	   /*
	      Drawing an oval with the same parameters would write
	      over the arc. In other words, the arc is like the
	      following oval, with most of it (all but 90 degrees,
	      the arcLength) removed.
         g.drawOval(200, 200, 80, 80);
	   */
	   g.setColor(Color.blue);
	   g.drawRect(200, 200, 80, 80);
	   g.fillOval(235, 235, 10, 10);
	   g.setColor(Color.black);
	   g.drawLine(240, 200, 240, 240);
	   g.drawLine(240,240, 280, 240);
 	   g.drawString("The arc extends past vertical, ", 300, 220);
 	   g.drawString("which means that arcLength", 300, 235);
 	   g.drawString("is the number of degrees in the arc,", 300, 250);
 	   g.drawString("not it's stopping point.", 300, 265);
	}
}