This has to how the paint engine deals of opaque components. Basically, when dealing with opaque components, the paint engine doesn't prepare the background the component (that is, it won't paint what is actually behind the component). Instead, it leaves it up to the component at hand to "clear" the Graphics
context as is needed.
Try making the button transparent by using setOpaque(false)
Updated
The major problem is you're supply alpha based colors (new Color(0, 0, 0, 0)
) to opaque components. This means that the paint engine does not consider the components it is painting to be transparent, so it makes no special effort to prepare the Graphics
context, but when the component tries to fill it's content (with the background color), it is filling it with a transparent color, which is pretty much the same as not calling super.paintComponent
.
Make ALL your JPanel
based components transparent except the base panel.