JLayeredPane isnt displaying
In my applet, I have a layered pane, but it isnt showing. Can you tell me why?
Code:
import javax.swing.*;
import java.awt.*;
public class birthday extends JApplet
{
JPanel panel;
JLayeredPane pane;
JLabel background;
ImageIcon card;
JButton enter;
JLabel label;
JPasswordField pass;
JProgressBar progress;
public void init()
{
setLayout(new FlowLayout());
setSize(700, 600);
pane = new JLayeredPane();
pane.setPreferredSize(new Dimension(400, 410));
card = new ImageIcon(getClass().getResource("jfdlk.png"));
background = new JLabel();
background.setIcon(card);
//background.setOpaque(true);
//pane.add(background, 1);
enter = new JButton("Press Me!");
//pane.add(enter, JLayeredPane.DEFAULT_LAYER);
pane.add(enter, new Integer(1));
JButton t2 = new JButton();
t2.setBackground(Color.white);
pane.add(t2, new Integer(0));
//panel = new JPanel();
//panel.add(pane);
//panel.add(enter);
add(pane);
//add(enter);
//getContentPane().add(panel);
}
}
Re: JLayeredPane isnt displaying
Never mind I figured it out, there was not layout in the pane, so I had to set the bounds myself. thanks anyway. But I do have a question, why must you put new Integer(x) in pane.add()? Why can't you just put x?