Painting in the Applet

This applet paints text and shapes to the display by overriding the paint() method.

  public void paint(Graphics g) {

    g.drawString("Hello Everyone!", 20, 30);

    g.drawRect(25, 45, 80, 80);

    g.drawOval(45, 67, 10, 10);
    g.drawOval(85, 67, 10, 10);
    g.drawArc(45, 95, 50, 10, 180, 180);

  }

Source code.
And before we finish we should show how to paint an image in the applet.

next page...


Last updated March 20, 1997 / ratliff@Princeton.EDU