这只是带有按钮的GUI的代码。如何使用ActionListener计算点击次数?谢谢!
import javax.swing.*;
import java.awt.*;
public class Xyz extends JFrame {
public Xyz() {
super("");
setSize(500, 500);
GridLayout grid = new GridLayout();
setLayout(grid);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton("Press");
add(button);
setVisible(true);
}
public static void main(String[] args) {
Xyz z = new Xyz();
}
}