First Shapes


import java.awt.*; //import Abstract Windowing Tool
import java.applet.Applet; //import Applet library
public class FirstShapes extends Applet { //who can run the file, name of file, extension program
public void paint(Graphics g) { //bring in paint method

g.drawRect(30, 30, 80, 40); //draw rectangle
g.drawOval(120, 30, 50, 50); //draw circle
g.setColor(Color.black); //set color to black
g.fillRect(30, 100, 80, 40); //draw filled rectangle w/ color
g.fillOval(120, 100, 50, 50); //draw filled circle w/ color
g.drawLine(30, 160, 130, 170); //draw line
g.drawArc(30, 180, 50, 50, 60, 40); //draw arc
g.fillArc(120, 180, 50, 50, 60, 40); //draw filled arc
}
}
© 2005 Toby Hsieh