//  File: TwoPolygons.java
//
//  Demonstrate the two ways to create a Polygon
//  Draw each Polygon and a PolyLine

import java.applet.*;
import java.awt.*;

public class TwoPolygons extends Applet {

    public void init() {
        setBackground(Color.LIGHT_GRAY.brighter());

        // create polygon1 using addPoint
        polygon1 = new Polygon();
        polygon1.addPoint(20, 20);
        polygon1.addPoint(120, 20);
        polygon1.addPoint(70, 120);

        // create polygon2 using a pair of arrays, x and y
        polygon2 = new Polygon(x2, y2, x2.length);
    }

    public void paint(Graphics g) {
        // draw polygon1
        g.setColor(Color.BLUE);
        g.fillPolygon(polygon1);
        // draw polygon2
        g.setColor(Color.GREEN);
        g.fillPolygon(polygon2);
        // draw a polyline
        g.setColor(Color.BLACK);
        g.drawPolyline(x3, y3, x3.length);
        // display the status line
        showStatus("               Two polygons and a polyline");
    }

    private Polygon polygon1, polygon2;
    private int[] x2 = { 140, 240, 190 };
    private int[] y2 = {  20,  20, 120 };
    private int[] x3 = {  20,  65, 110, 150, 195, 240 };
    private int[] y3 = { 140, 160, 120, 170, 135, 160 };

} // end class TwoPolygons
