September 8, 2003

A basic applet with some simple graphics commands.



/*
 A basic applet that uses simple graphics */
import java.awt.*;
   import java.applet.Applet;
public class Hello extends Applet
{
   public void paint(Graphics g) {
   
   // Set the background to yellow
   setBackground(Color.yellow);
   
   // Draw a white filled cirlce/pie
   g.setColor(Color.white);
   g.fillArc(100, 50, 120, 120, 45, 90);
   
   g.setColor(Color.black);
   g.drawString("Hello there!", 100, 130);
   
   // set the drawing color to red
   g.setColor(Color.red);
   
   g.drawString("This is in red.", 50, 150);
   }
}
 
Back to class exmaples | Back to CS110 Materials page