Java examples for 2D Graphics:Rectangle
get Rectangle
//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); } }