tags:

views:

75

answers:

4
+1  Q: 

swing root pane

I understood that every top level container has some layers:

root pane
layer pane
content pane
glass pane

but I didn't understand if the root pane is the top level container itself...

which is the equivalence between a pane and a container? In fact when I return a pane with getContentPane() the object is a Container type!

+2  A: 

You also have a JFrame. Read more on How to Use Root Panes.

RootPaneContainer From JRootPane:

The "heavyweight" components (those that delegate to a peer, or native component on the host system) are shown with a darker, heavier box. The four heavyweight JFC/Swing containers (JFrame, JDialog, JWindow, and JApplet) are shown in relation to the AWT classes they extend. These four components are the only heavyweight containers in the Swing library.

Jonas
+1  A: 

Have a look here.

Bozhidar Batsov
+1  A: 

See also, Using Top-Level Containers.

trashgod
+1  A: 

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, JInternalFrame 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.

jfpoilpret