By default, components don't have position or size, meaning if you add them to a container that has no layout manager (as is the case with JLayeredPane
), they will not appear.
Because JLayeredPane
has no layout manager, you must take over the responsibility of provide position and size information to your components.
Try using setSize
, setLocation
and/or setBounds
.
Take a look at the examples from How to use layered panes for more details.