package Demo;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class chuangkou implements ActionListener{
JFrame f;
JPanel p;
JButton b;
JLabel l;
public chuangkou() {
f=new JFrame();
p=new JPanel(null);
b=new JButton("确定");
l=new JLabel();
b.addActionListener(this);
f.add(p);
p.add(b);
p.add(l);
f.setVisible(true);
f.setSize(400,400);
l.setBounds(50,120,50,50);
b.setBounds(150,150,80,80);
}
public static void main(String[] args) {
new chuangkou();
}
public void actionPerformed(ActionEvent e) {
p.setBackground(Color.pink);
l.setText("嘿嘿嘿嘿嘿");
b.setBounds(250,50,80,80);
}
}
![1634264-20190508115707180-877254995.png](https://i-blog.csdnimg.cn/blog_migrate/2168ef9e239e3c08bbffc22b21376063.png)
![1634264-20190508115717104-375986298.png](https://i-blog.csdnimg.cn/blog_migrate/594972344add6c14fa4bd91425cfd010.png)