Shape (float x, float y, float width, int height, int thickness, boolean rounded) { if (width <= 0 || height <= 0) return null; Shape outer = rounded ? new RoundRectangle2D.Float(x, y, width, height, 2, 2) : new Rectangle2D.Float(x, y, width, height); int doubleThickness = 2 * thickness; if (width <= doubleThickness || height <= doubleThickness) return outer; Shape inner = new Rectangle2D.Float(x + thickness, y + thickness, width - doubleThickness, height - doubleThickness); Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD); path.append(outer, false); path.append(inner, false); return path; }