package app;
import java.awt.*;
import javax.swing.*;
public class JPanel {
public static void main(String[] args){
new WindowLayered();
}
}
class WindowLayered extends JFrame{
WindowLayered(){
setBounds(100,100,300,300);
setVisible(true);
JLayeredPane pane = new JLayeredPane();
JButton a1 = new JButton("我在DEFAULT_LAYER"),
a2 = new JButton("我在PALETTE_LAYER"),
a3 = new JButton("我在MODAL_LAYER"),
a4 = new JButton("我在POPUP_LAYER"),
a5 = new JButton("我在DRAG_LAYER");
pane.setLayout(null);
pane.add(a5,JLayeredPane.DRAG_LAYER);
pane.add(a4,JLayeredPane.POPUP_LAYER);
pane.add(a3,JLayeredPane.MODAL_LAYER);
pane.add(a2,JLayeredPane.PALETTE_LAYER);
pane.add(a1,JLayeredPane.DEFAULT_LAYER);
a5.setBounds(50,50,200,100);
a4.setBounds(40,40,200,100);
a3.setBounds(30,30,200,100);
a2.setBounds(20,20,200,100);
a1.setBounds(10,10,200,100);
add(pane);
validate();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}