The JLayeredPane serves as the main component container of a JRootPane. : JLayeredPane « Swing « Java Tutorial






Integer layer = new Integer(20);
aLayeredPane.add(aComponent, layer);

Using public void setLayer(Component comp, int layer) or public void setLayer(Component comp, int layer, int position) method before adding the component to the JLayeredPane.

aLayeredPane.setLayer(aComponent, 10);
aLayeredPane.add(aComponent);








14.52.JLayeredPane
14.52.1.JLayeredPane Layer Constants
14.52.2.Implement buttons at different layers
14.52.3.The JLayeredPane serves as the main component container of a JRootPane.
14.52.4.Moves an image of Duke around within a layered pane in response to mouse motion events.Moves an image of Duke around within a layered pane in response to mouse motion events.