get Rectangle - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

get Rectangle

Demo Code


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

public class Main {
    public static Polygon getRectangle(int topLeftX, int topLeftY,
            int bottomRightX, int bottomRightY) {
        int[] xPoints = new int[] { topLeftX, topLeftX, bottomRightX,
                bottomRightX };// w  w w.ja v a 2s . c  om
        int[] yPoints = new int[] { topLeftY, bottomRightY, bottomRightY,
                topLeftY };
        return new Polygon(xPoints, yPoints, 4);
    }
}

Related Tutorials