In Segment 669, you learned that containers contain components and that containers are components.
In particular, a JFrame
instance is a container that
contains a
variety of component instances, one of which is the content pane,
which itself can contain components. The following diagram shows how
various components contained by a JFrame
instance nest together.
Note especially that the content panegenerally a JPanel
instancecan contain components such as
JComponent
instances.
*--- JRootPane | *-- JLayeredPane | | *-- JMenuBar | | | *-- JPanel (the content pane) v | | | *----- v --- | --- | -------------------------------------------* |*---------- v --- | ------------------------------------------*| ||*--------------- | -----------------------------------------*|| ||| | ||| ||*--------------- | -----------------------------------------*|| || v || ||*-----------------------------------------------------------*|| ||| ||| ||| *----* *----* *----* ||| ||| | | | | | | ||| ||| | | | | | | <--- components (one or more) ||| ||| | | | | | | ||| ||| *----* *----* *----* ||| ||| ||| ||*-----------------------------------------------------------*|| |*-------------------------------------------------------------*| *---------------------------------------------------------------*