0

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?

PowerStat
  • 3,757
  • 8
  • 32
  • 57
Sathiya
  • 1
  • 2
  • this issue here were asked and solved a few times, (AFAIK repeatly for JButton), search here for question about JButton and rounded corners – mKorbel Dec 19 '13 at 14:40
  • This has been already discussed – Aroon Dec 19 '13 at 14:40
  • Please edit your question to include an [sscce](http://sscce.org/) that uses your border and exhibits the problem you describe. – trashgod Dec 19 '13 at 22:14

0 Answers0