日期:2014-05-20 浏览次数:20732 次
package ch5; import java.awt.BorderLayout; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JPanel; public class JLayeredPaneTest extends Frame { public JLayeredPaneTest() { final int x=new Integer(100); int y=new Integer(200); JLabel j=new JLabel("sadasdsadsadsadsa"); JLabel j1=new JLabel("萨达是决定离开撒娇sadasjdsal"); j.setBounds(20,20,100,100); j1.setBounds(20,20,100,100); JLayeredPane main=new JLayeredPane(); JLayeredPane submain=new JLayeredPane(); main.setLayout(new BorderLayout()); JButton b1=new JButton("往上一层"); JButton b2=new JButton("往下一层"); JPanel jpanel=new JPanel(); jpanel.add(b1); jpanel.add(b2); main.add(jpanel,BorderLayout.SOUTH); submain.add(j,x ); submain.add(j1,y ); main.add(submain,BorderLayout.CENTER);} public static void main(String[] args) { JLayeredPaneTest sa=new JLayeredPaneTest(); sa.setBounds(100,100,500,500); sa.setVisible(true); } }