Vertical sequence of components.
publicclass LayoutTestextends JFrame{
public LayoutTest(){
this.setLayout(null);
JButton bt1 =new JButton("button1");
bt1.setBounds(0, 0, 100, 40);
JButton bt2 =new JButton("button2");
bt2.setBounds(0, 50, 100, 40);
JButton bt3 =new JButton("button3");
bt3.setBounds(0, 100, 100, 40);
JPanel p1 =new JPanel();
p1.setLayout(null);
p1.setBackground(Color.green);
p1.setBounds(50, 50, 100, 150);
p1.add(bt1);
p1.add(bt2);
p1.add(bt3);
JLabel label =new JLabel("hello!");
label.setBounds(140, 100, 100, 50);
label.setBackground(Color.orange);
label.setOpaque(true);
JLayeredPane layer =new JLayeredPane();
layer.add(label,new Integer(1));
layer.add(p1,new Integer(2));
this.setContentPane(layer);
this.setSize(300,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
publicstaticvoid main(String args[]){
LayoutTest lt =new LayoutTest();
lt.setVisible(true);
}
In this code, I was trying to put a JLabel component on a JPanel components. But whatever I do, the JLabel component is always under the JPanel component.
Is there somebody can explain what is the problem, and how to fix this problem.
Many thanks.

