Reputation: 81
I am writing in java some kind of application and i have to place something in front of another objects( in Z order) I know that that i should use JLayeredPane but in fact i am not very familiar with it. My idea is to make two JPanel's with different Z-order factors while inserting them to JLayeredPane. i pasted my code http://www.wklejto.pl/130038 i would be very grateful if you tell me what is wrong because i am doing it for a long of time with no effect.
Upvotes: 2
Views: 3094
Reputation: 5989
I don't see anything wrong with this code. Maybe you're trying to paint a transparent (not opaque) JPanel
(e.g. with message) on top of the underlying base JPanel
.
In that case you should invoke setOpaque(false)
on your front JPanel
.
JPanel second = new JPanel();
second.setOpaque(false);
second.add(new JLabel("message"));
jlp.add(second, new Integer(300));
JPanel
s are opaque by default - on the other hand JLabel
s aren't.
And take a look into tutorial.
Upvotes: 1