import java.awt.Rectangle; import javax.swing.JButton; /** private static final long serialVersionUID = 4785452373598819719L; private JButton b_a = null, b_b = null; private JLayeredPane lp = null; // 我们要用到的层 public Test() { lp = this.getLayeredPane(); // 获取JLayeredPane b_a = new JButton("A"); b_a.addActionListener(this); // 按钮事件 lp.add(b_a, new Integer(200)); // 将组件添加到JLayeredPane中,指定所在的层 b_a.setBounds(new Rectangle(100, 100, 100, 100)); // Button出现位置 b_b.setBounds(new Rectangle(50, 50, 100, 100)); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); public void actionPerformed(ActionEvent e) { public static void main(String args[]) { } |
Java中层JLayeredPane使用的小例子
最新推荐文章于 2022-05-26 22:01:48 发布