- The default layout of a
JFrame
(or more specifically in this case, the content pane of the frame) is aBorderLayout
. - When adding a component to a
BordeLayout
with no constraint, the Swing API will put the component in theCENTER
. - A
BorderLayout
can contain exactly one component in each of the 5 layout constraints. - When a second component is added to the same (in this case
CENTER
) constraint of aBorderLayout
, this implementation of Java will display the last component added.
As to what would be a better approach depends on the specific needs of the user interface.