Q:

How to create an image with rounded corners in Java?

When I draw the BufferedImage with rounded corners
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
graphics.setColor(Color.WHITE);
graphics.fill(new RoundRectangle2D.Float(0, 0, 60, 60, 20, 20));

The output image is:

How can I receive an image without black cornerns?

A:

Change BufferedImage.TYPE_INT_RGB to BufferedImage.TYPE_INT_ARGB to create a transparent image

