Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

So many window Panes in JFrame?  RSS feed

 
Prosenjit Banerjee
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These panes are pains for me. Just was reading in a book that a JFrame contains a number of panes namely : JRoot, JLayeredPane, ContentPane Glass pane. Why are there so many panes? Whare are their uses?
Again, why should we attatch a JPanel with the contentPane of a JFrame in order to draw something? Why can't we directly draw something directly on the JFrame?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could. But then you couldn't use the facilities that JFrame offers. For example, the glass pane can be used to block mouse input during long-running operations, or to draw some kind of overlay over the window. Using the content pane properly allows the root pane to manage a menu bar in the window.

But if you play by the rules -- most notably, by using a separate panel to paint in, rather than trying to paint right on the frame -- then you get these capabilities for free. You don't even need to think about them if you don't use them directly. Many basic Swing programmers are completely unaware that they exist.

If you haven't already, you might like to read this page about how the pieces of a JFrame fit together.

I'm moving this to our Swing/AWT forum for any further discussion.
 
Prosenjit Banerjee
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. You helped me a lot. Specially the java tutorial referred by you gave me a great knowledge.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!