鼠标点击速度游戏

题目:

  利用Java Swing 技术设计一个鼠标点击速度比费游戏程序。程序显示一个按钮和文本框。用户点击按钮,文本框显示鼠标点击次数。两个人同时运行本程序,即进行比赛。


程序:

package assr;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Game {
public static void main(String[] args) {
new MyFrame(” 鼠标点击大比拼”);
}

}
@SuppressWarnings(“serial”)
class MyFrame extends JFrame implements ActionListener{
JLabel explainLabel=new JLabel (” 点击次数”);
JTextField text=new JTextField(”          “);
int count=0;
JButton button=new JButton(“请连续点击”);
public MyFrame(String title) {
setTitle(title);
setLayout(new FlowLayout()); 
add(explainLabel);
add(text);
button.addActionListener(this);
add(button);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,200,200);
pack();
}
@Override
public void actionPerformed(ActionEvent e) {
count++;
text.setText(” “+count+” “);
}
}

《鼠标点击速度游戏》

    原文作者:爱昵555
    原文地址: https://blog.csdn.net/qq_40594776/article/details/78919198
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞