wood burning stoves*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JLayeredPane vs JPanel" Watch "JLayeredPane vs JPanel" New topic
Author

JLayeredPane vs JPanel

Micah Pezdirtz
Greenhorn

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: 15299
    
    6

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
 
 
subject: JLayeredPane vs JPanel