Draws a solid polygon in the specified color. - Java 2D Graphics

Java examples for 2D Graphics:Polygon

Description

Draws a solid polygon in the specified color.

Demo Code


//package com.java2s;
import java.awt.*;

public class Main {
    /** Draws a solid polygon in the specified color. */

    public static void fillPolygon(Graphics g, int[] xs, int[] ys,
            int numPoints, Color c) {
        Color origColor = g.getColor();
        g.setColor(c);/*from   www. j  a  v a  2  s.  co m*/
        g.fillPolygon(xs, ys, numPoints);
        g.setColor(origColor);
    }

    /** Draws a solid polygon in the specified color. */

    public static void fillPolygon(Graphics g, Polygon p, Color c) {
        Color origColor = g.getColor();
        g.setColor(c);
        g.fillPolygon(p);
        g.setColor(origColor);
    }
}

Related Tutorials