Some Graphis Notes




//draw house
g.setColor(Color.green);
g.drawLine(0, 350, 400, 350);

g.setColor(Color.red);
g.drawRect(100, 200, 150, 150);
g.setColor(Color.black);
g.fillRect(150, 275, 50, 75);
g.drawPolygon(xPoints, yPoints, 3);
g.setColor(Color.yellow);
g.fillOval(300, 75, 50, 50);
Advanced
To use the drawPolygon command we must first create 2 integer arrays with the x and y coordinates of the points we want to connect. In the example below we are connecting points 75,200 to 175,250 to 275,200. The third argument in the drawpolygon command is the size of the arrays.

int xPoints[] = {75, 175, 275};
int yPoints[] = {200, 250, 200};