/** * Applies the shape to window. It is recommended to apply shape in * componentResized() method */ @Override public void componentResized(ComponentEvent e) { int h = getHeight(); int w = getWidth(); float a = (float) Math.hypot(h, w); Float path = new java.awt.geom.Path2D.Float(); path.moveTo(0, 0); path.lineTo(w, 0); path.lineTo(0, h); path.closePath(); path.moveTo(W, W); path.lineTo(W, h - W * (a + h) / w); path.lineTo(w - W * (a + w) / h, W); path.closePath(); setShape(path); }
public Shape buildShape() { int h = getHeight(); int w = getWidth(); float a = (float) Math.hypot(h, w); Float path = new java.awt.geom.Path2D.Float(); path.moveTo(0, 0); path.lineTo(w, 0); path.lineTo(0, h); path.closePath(); path.moveTo(W, W); path.lineTo(W, h - W * (a + h) / w); path.lineTo(w - W * (a + w) / h, W); path.closePath(); return path; }