getContentPane() and getRootPane()
Posted on 2009-06-29
Top level containers are such as the JFrame, JPanel and so on. Now we cannot directly add a component to a swing container (top level container). We can only add components to the container ContentPane by calling the getContentPane() method. Also a RootPane cannot have children. Therefore we cannot add components to the RootPane. Instead we can add components to the ContentPane of the RootPane. A RootPane is used to manage the interior of a frame such as the ContentPane, LayeredPane, GlassPane and MenuBar. Is this why we can set a JMenuBar on a RootPane?.