Java control Z-order JPanels

In short, my need is to have a background image in my java application, and at some event, create different graphics on top of that image.

I thought I would use JPanel to draw a background image, add it to my JFrame at the beginning of the program, and then add other JPanels on top of it for certain events. The problem is that Swing gives JPanels by adding the first highest index Z, so that my background will be displayed on top of everything.

Is there a way to manage the Z index / order of JPanels, or am I completely wrong about that?

+5
source share
4 answers
+12

, mutiple JPanels z-. ONE JPanel paintComponent (Graphics g), .

CardLayout JLabels ( ), , ,

CardLayout cl = (CardLayout)getLayout();
cl.show(this, "card3");

JLabel.

+2
+2

, JPanel , JFrame ,

.

JPanels . Swing JPanels Z, .

- . . Z-Order.

. , , , .

Perhaps the Background Bar may help you. It automatically turns any component added directly to the panel, opaque.

+1
source

All Articles