Page 2 - Drawing Shapes

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

public class Page2Shapes extends Applet {

int width, height; // Declare variables for the width & height of objects

public void init() {
width = getSize().width;
height = getSize().height;
setBackground( Color.black );
}
public void paint( Graphics g ) {

// the origin (0,0) is at the upper left corner.
// x increases to the right, and y increases downward.

g.setColor( Color.green ); // sets the drawing color
g.drawRect( 10, 20, 100, 15 ); // draws a rectangle shape, colored outline
g.setColor( Color.red );
g.fillRect( 240, 160, 40, 110 ); // draws & fills a rectangle shape with color

g.setColor( Color.orange );
g.drawOval( 50, 225, 100, 50 ); // draws a oval shape, colored outline
g.setColor( Color.blue );
g.fillOval( 225, 37, 50, 25 ); // draws & fills a oval with color

g.setColor( Color.pink );
g.drawArc( 10, 110, 80, 80, 90, 180 ); // draws a arc shape, colored outline
g.setColor( Color.yellow );
g.fillArc( 140, 40, 120, 120, 90, 45 ); // draws & fills a arc with color
}
}