{noformat}Hi,{noformat}
I'm trying to create a rounded JDialog, with anti-aliasing applied to the edges. To set the window shape, I use the following code:
RoundRectangle2D.Double roundRect = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 15, 15);
AWTUtilities.setWindowShape(this, roundRect);
This will round the edges of my JDialog, but no anti-aliasing is applied. To enable anti-aliasing for this dialog, I've created this paint method:
@Override
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
RenderingHints rh = new RenderingHints(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHints(rh);
RoundRectangle2D.Double roundRect = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), 15, 15);
AWTUtilities.setWindowShape(this, roundRect);
super.paint(g2);
RoundRectangle2D.Double roundRect2 = new RoundRectangle2D.Double(1, 1, getWidth() - 3, getHeight() - 3, 15, 15);
g2.draw(roundRect);
}
roundRect2 is anti-aliased, but the roundRect isn't. Any ideas please on what I'm doing wrong, or how I can achieve the desired effect?
Thanks.