Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JLayeredPane vs JPanel

 
Micah Pezdirtz
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic