Project 25

Learning the Microsoft J++ enviornment part II - (25 points)
This project is designed to allow you to get acquainted with the Microsoft J++ enviornment. Type the project25.java applet in the J++ text editor. Also, Compile, Build, and Execute the Applet. Include your name, date, project#, and a brief description at the top of this and all projects.


//Project25.java
/*Name :               Date :           Project25
Description :
*/
import java.applet.*;
import java.awt.*;

public class Project25 extends Applet
{
	byte width=25, height=75, dirwi=1, dirhe=-1, dirco=1;
	short color=0;

	public void init()
	{
		setBackground(new Color(0,0,0));
	}

	public void setup(Graphics g)
	{
		g.setColor(new Color(255,255,255));
		g.drawRect(0,0,100,25);
		g.drawString("Clear Applet",5,16);
	}

	public boolean mouseDrag(Event evt, int x, int y)
	{
		Graphics g;
		g=getGraphics();
		if (x>100 || y>25)
		{
			if ((color+=dirco)==255) dirco=-1;
			else if (color==0) dirco=1;
			if ((width+=dirwi)==100) dirwi=-1;
			else if (width==25) dirwi=1;
			if ((height+=dirhe)==100) dirhe=-1;
			else if (height==25) dirhe=1;
			g.setColor(new Color(255-color,color,0));
			g.drawOval(x, y, width, height);
		}
		else
			setup(g);
		g.dispose();
		return true;
	}

	public boolean mouseDown(Event evt, int x, int y)
	{
		Graphics g;
		g=getGraphics();
		if (x<100 && y<25)
			g.clearRect(0, 0, 200, 200);
		setup(g);
		g.dispose();
		return true;
	}
}

Sample Output for Project25.java

This applet was created by Northridge High School Student Keith Lantz - April 1998.
Click and Drag your mouse over the applet.