[ACCEPTED]-Java : set a Component on top of another-jpanel
Accepted answer
You could replace your main JPanel with 3 a JLayeredPanel. A layered panel will let 2 you specify that some child components should 1 be layered above other child components.
I.e.:
JLayeredPane pane = new JLayeredPane();
JLabel ontop = new JLabel("On top");
JLabel behind = new JLabel("Behind");
pane.add(ontop, 2, 0);
pane.add(behind, 1, 0);
Make your main JPanel a JLayeredPane
Then you can set 2 the layer of the other components with setLayer(Component c, int layer)
thus 1 allowing them to overlap.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.