I have two panels that are layered on a JLayeredPane. The default layer contains an image. The top layer has a circle that is transparent and I can see part of the default layer image through it. I however want the transparent layer to be bigger than the default layer so that the image behind does not ever show on the sides.

// This works but shows the image behind by 1 pixel which I do not want
JLayeredPane layeredPane = new JLayeredPane();
bottomLayer.setBounds(10, 10, 550, 500); //defaultLayer panel
topLayer.setBounds(11, 0, 620, 580)); // modalLayer panel

//this does not work and makes the default panel with the image not show anymore
JLayeredPane layeredPane = new JLayeredPane();
bottomLayer.setBounds(20, 0, 550, 500)); //defaultLayer panel
topLayer.setBounds(10, 0, 620, 580)); // modalLayer panel
0

There are 0 best solutions below