The moose likes Swing / AWT / SWT and the fly likes JLayeredPane vs JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLayeredPane vs JPanel" Watch "JLayeredPane vs JPanel" New topic

JLayeredPane vs JPanel

Micah Pezdirtz

Joined: Aug 14, 2006
Posts: 25
i want to use a JLayeredPane because you can put things at different depths. but i recently found that JPanel also has some sort of layer positioning system. what is up with this? is JLayeredPane just an easy way to use the layers that are already in JPanel? what makes JLayeredPane's jayers better than JPanels layers? somebody straighten me out about this please.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Interesting observation. Though I don't think JPanels are really layered. At least not like JlayeredPanes. Personally, the only time I have used a JLayeredPane is for a pallette which I needed to float above all other layers.

See, if you wanted to use a JPanel for such things, you would basically have to create a focus listener and pop the JPanel to the front anytime it lost focus. with a JLayeredPane you simply specify the "z-order" and java takes care of the rest.

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: JLayeredPane vs JPanel
It's not a secret anymore!