import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//ActionListener:动作监听(鼠标点击、空格按下)
public class ActionListenerTest1 {
    public static void main(String[] args) {
        JFrame f=new JFrame();
        f.setSize(500,500);
        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        f.setLayout(null);

        JButton jl1=new JButton("按钮");
        jl1.setBounds(0,0,100,100);
        f.getContentPane().add(jl1);
        jl1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("我被点过了!!!");
            }
        });
        f.setVisible(true);
    }
}