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?
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.