O'Reilly logo

Java Swing, 2nd Edition by Brian Cole, James Elliott, Marc Loy, Robert Eckstein, Dave Wood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Root Pane

Now that we’ve seen the simplest example of a Swing container, we’ll move on to something a bit more powerful. Most of the other Swing containers (JFrame, JApplet, JWindow, JDialog, and even JInternalFrame) contain an instance of another class, JRootPane , as their only component, and implement a common interface, RootPaneContainer . In this section, we’ll look at JRootPane and RootPaneContainer, as well as another class JRootPane uses, JLayeredPane .

Before jumping into the descriptions of these classes, let’s take a look at how the classes and interfaces that make up the Swing root containers fit together. Figure 8-2 shows that JApplet, JFrame, JDialog, and JWindow do not extend JComponent as the other Swing components do. Instead, they extend their AWT counterparts, serving as top-level user interface windows. This implies that these components (unlike the lightweight Swing components) have native AWT peer objects.

Swing “root” container class diagram

Figure 8-2. Swing “root” container class diagram

Notice that these Swing containers (as well as JInternalFrame) implement a common interface, RootPaneContainer . This interface gives access to the JRootPane’s properties. Furthermore, each of the five containers uses a JRootPane as the “true” container of child components managed by the container. This class is discussed later in this chapter.

The JRootPane Class

JRootPane is a special container that extends ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required