Hello!
I've made a custom JPanel that overrides paintComponent which paints a rounded rectangle. My problem is that when I place other components in the panel, like a JLabel, they don't get rounded corners like the panel they are in.
here is my panel class:
private static class BackgroundPanel extends DropShadowPanel {
/** Serial version UID. */
private static final long serialVersionUID = 4349330263921687004L;
public BackgroundPanel() {
super();
setBorder(new EmptyBorder(0,20,20,20));
}
/** {@inheritDoc} */
@Override
public boolean isOpaque() {
return false;
}
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2 = CommonUIPainter.getGraphics2D(g);
super.paintComponent(g2);
Insets insets = getInsets();
int x = insets.left;
int y = insets.top;
int w = getWidth() - insets.left - insets.right;
int h = getHeight() - insets.top - insets.bottom;
g2.setColor(getBackground());
g2.fillRoundRect(x, y, w, h, 20, 20);
}
}
So my question is how do I make it so that the panels children also get rounded corners?