import java.awt.*; // make the graphics libraries available
import java.applet.*; // make the applet libraries available
public class MovingCircle extends Applet // make a new applet
{
private int xCoord = 0; // distance from left hand side
private int yCoord = 0; // distance from the top
private int width = 40; // circle diameter
private int depth = 40; // circle diameter
public void paint(Graphics g) // this does the drawing
{
g.setColor(Color.blue); // set the pen colour blue
g.fillOval(xCoord, yCoord, width, depth); // draw the rectangle
g.drawString("Hello World", xCoord, yCoord + depth + 20); // write the string
xCoord = xCoord + 20; // move in 20 pixels from the left
yCoord = yCoord + 20; // move down 20 pixels from the top
}
}
|