private static final Shape createMask(int width, int height) { Shape outside = new Rectangle2D.Double(0, 0, width, height); Shape inside = new RoundRectangle2D.Double(10, 10, width - 20, height - 20, 50, 50); Area area = new Area(outside); area.subtract(new Area(inside)); return area; }