I am creating the rounded edge border in jpanel using the following code:
class RoundedBorder extends AbstractBorder {
public Insets getBorderInsets( Component c, Insets insets ) {
insets.left = insets.top = insets.right = insets.bottom = 25;
return insets;
}
public void paintBorder( Component c, Graphics g, int x, int y,
int width, int height) {
int w = width;
int h = height;
g.translate(x, y);
g.setColor( c.getBackground().darker() );
g.drawRoundRect( 0, 0, w-2, h-2, 30, 30 );
g.translate(-x, -y);
}
public boolean isBorderOpaque() {
return true;
}}
panel.setBorder(new RoundedBorder());
Works fine, but when I am changing the JPanel background color, JPanel will avoid the background color to make Rounded corner.
How to make rounded corner border to background color also?