package scr;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Myclick implements ActionListener {
JFrame f;
JPanel p;
JButton b;
JLabel l;
public Myclick() {
f=new JFrame();
p=new JPanel();
b=new JButton("点击");
b.addActionListener(this);
l=new JLabel();
p.add(b);
p.add(l);
f.add(p);
f.setSize(300,400);
f.setVisible(true);}
public static void main(String[]args){
new Myclick();
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO 自动生成的方法存根
l.setText("Hello");
p.setBackground(Color.red);
}
}