Example usage for java.awt Polygon reset

List of usage examples for java.awt Polygon reset

Introduction

In this page you can find the example usage for java.awt Polygon reset.

Prototype

public void reset() 

Source Link

Document

Resets this Polygon object to an empty polygon.

Usage

From source file:RedBlueBox.java

public void paintComponent(Graphics g) {
    Insets insets = getInsets();//from  w  w  w  . j  a va  2 s .c o  m
    int endX = getWidth() - insets.right;
    int endY = getHeight() - insets.bottom;
    // get the top-left corner
    int x = insets.left;
    int y = insets.top;

    g.setColor(Color.RED);
    Polygon p = new Polygon();
    p.addPoint(x, y);
    p.addPoint(endX, y);
    p.addPoint(x, endY);
    g.fillPolygon(p);
    g.setColor(Color.BLUE);
    p.reset();
    p.addPoint(endX, y);
    p.addPoint(x, endY);
    p.addPoint(endX, endY);
    g.fillPolygon(p);
}