The Rotating Disk Applet:
Code:
import java.applet.Applet;
import java.awt.*;
public class Rotating_Disk extends Applet
{
//===========================================================
// Uses ovals to simulate a rotating disk.
//===========================================================
public void paint (Graphics page)
{
int width = 0, height = 60; // initial size
int x = 120, y = 120; // position
int warp = 1; // shrink/growth factor
page.setXORMode (getBackground());
for (int change=1; change < 500; change++)
{
width = width + warp * 2;
x = x - warp;
if (width == 0 || width == 60)
warp *= -1; //switch between growing and shrinking
// print oval
page.fillOval (x, y, width, height);
for (int pause=1; pause <= 1000000; pause++);
// erase oval
page.fillOval (x, y, width, height);
}
}
}