Java examples for 2D Graphics:Rectangle
Get Rectangle corners
//package com.java2s; import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; import java.util.List; public class Main { public static List<Point> corners(Rectangle region) { List<Point> list = new ArrayList<Point>(); list.add(new Point(region.x, region.y)); list.add(new Point(region.x, region.y + region.height)); list.add(new Point(region.x + region.width, region.y)); list.add(new Point(region.x + region.width, region.y + region.height));/*from w ww . j ava2 s. c o m*/ return list; } }