How to get the name of the panel your JLayeredPane is on

47 Views Asked by At

Throughout my program, I use JLayeredPane a lot to layer panels. To traverse through these panels, I typically have code similar to this:

jLayeredPane.removeAll();
jLayeredPane.add(jPanel4);
jLayeredPane.revalidate();
jLayeredPane.repaint();

In a different method, how am I able to see what panel I am on (or have added)? Would I only be able to do this with a variable indicating the panel or could I use getLayer() or something along those lines?

I have tried getLayer(), however I don't really know how to quite use it as I would not be able to do something like jLayeredPane.getLayer(jLayeredPane);. So how do I properly see what panel I have added to my layered pane?

0

There are 0 best solutions below