最佳答案:JButton button = new JButton("按钮");button.addActionListener(new ActionListener() { public void actio
JButton button = new JButton("按钮");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 此处添加需要处理的信息
}
});
一般两种 一种就像我给你写的这个一样 另一种是写个实现了 ActionListener接口的实现类 然后把这个实现类实例化 放进addActionListener()中。一般常用我这种 。