I understand that every top level container has some layers:
root pane
layer pane
content pane
glass pane
but I don't understand whether the root pane is the top level container itself.
What is the relationship between a pane and a container? In fact, when I return a pane with
getContentPane()
, the object is of type Container
!
If you take a look at the previous answers or links, you will find out, between the lines, that the actual answer to the question is:
The root pane IS NOT the top-level container itself, but the top-level container HAS a root pane.
Since all Swing top-level containers (namely, JFrame
, JDialog
and JApplet
) implement the RootPaneContainer
interface, this means that you can gain access to their root pane in a general way (no need to check if this is a JFrame
or JDialog
....)
About the second part of the question, the difference between pane and container, actually there is no difference, a pane is a java.awt.Container
(or any subclass, in particular javax.swing.JPanel
).
What is important to udnerstand is the various panes that exist in a Swing top-level container (root, content, glass, layered), for this you have to take a look at the links posted in previous answers.