I have a JButton with FlatLaf GUI.
FlatLaf allow me set client properties to some components, in this case I use 'JButton.buttonType' property
Example:
JButton myButton = new JButton();
myButton.putClientProperty("JButton.buttonType","roundRect");
And this paints a rounded button.
The problem occurs when I send an Icon to the button
myButton.setIcon(new ImageIcon(getClass().getResource("/path/image.png")));
And this paints the image like:
As can be seen, this paints the image using the rectangle of my button. The borderPaint can be seen, and effectively is a perfect circle, but the border corners always show.
How can I remove those corners?
You could create a custom Icon class:
Above code should paint an oval of the image based on the width and height of the original image.