Java Reference
In-Depth Information
tooltip text appear in front of any other Swing components. In the back is the
JLayeredPane
,
which contains an optional
JMenuBar
on top and a content pane (
Container
) below it in another
layer. It is within the content pane that you would normally place components in the
JRootPane
. Figure 8-1 should help you visualize how the
RootLayout
lays out the components.
*-ENU"AR
#ONTENT0ANE#ONTAINER
'LASS0ANE#OMPONENT
Figure 8-1.
JRootPane containment diagram
■
Note
A
JLayeredPane
is just another Swing container (it's described later in this chapter). It can contain
any components and has a special layering characteristic. The default
JLayeredPane
used within the
JRootPane
pane contains only a
JMenuBar
and a
Container
as its content pane. The content pane has
its own layout manager, which is
BorderLayout
by default.
Creating a JRootPane
Although the
JRootPane
has a public no-argument constructor, a
JRootPane
isn't something
you would normally create yourself. Instead, a class that implements the
RootPaneContainer
interface creates the
JRootPane
. Then, you can get the root pane from that component, through
the
RootPaneContainer
interface, described shortly.
JRootPane Properties
As Table 8-1 shows, there are 11 properties of
JRootPane
. In most cases, when you get or set one
of these properties for a top-level container, like
JFrame
, the container simply passes along the
request to its
JRootPane
.
The glass pane for a
JRootPane
must not be opaque. Because the glass pane takes up the
entire area in front of the
JLayeredPane
, an opaque glass pane would render the menu bar and
content pane invisible. And, because the glass pane and content pane share the same bounds,
the
optimizedDrawingEnabled
property returns the visibility of the glass pane as its setting.