Stack of transparent JPanel
Hello everybody,
I'm trying to program an application where I have a stack of Jpanels on my contentPane.
I want all JPanels to be transparent but the "lowest" one, so that I can see essentially the content of all JPanels.
I try it with two JPanles but it seems not to work.
here is my code:
privatevoid createAndShowGUI(){
JFrame frame =new JFrame("MultiplePanels");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
Container pane = frame.getContentPane();
JPanel panel1 =new JPanel(new BorderLayout());
JLabel label1 =new JLabel("label1");
panel1.add(label1, BorderLayout.EAST);
JPanel panel2 =new JPanel(new BorderLayout());
panel2.setOpaque(false);
JLabel label2 =new JLabel("label2");
panel2.add(label2, BorderLayout.WEST);
pane.add(panel1);
pane.add(panel2);
frame.setVisible(true);
}
At the moment it shows only the secon JPanel saying "label2" at the west side of the panel, also I set this panel to be transparent.
Do you know what I'm doing wrong?
Can you help me?
Thank you very much,
Stefan

