- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class shubiaodj extends JFrame implements ActionListener {
- JTextField tf;
- int a;
- shubiaodj(){
- JFrame jf = new JFrame("鼠标点击速度大比拼");//软件名称
- jf.setVisible(true);
- jf.setSize(250, 200);//设置窗口体积
- jf.setLocationRelativeTo(null);
- JLabel jl=new JLabel("点击次数");//标签
- tf= new JTextField(10);// 文本框
- JButton but= new JButton("请连续点击");//Button按钮
- but.addActionListener(this);
- jf.add(jl);
- jf.add(tf);
- jf.add(but);
- jf.setLayout(new FlowLayout());
- }
- public void actionPerformed(ActionEvent e){
- String s = e.getActionCommand() ;
- if(s.equals("请连续点击"))
- tf.setText(""+a++);
- }
- public static void main(String[] args) {
- new shubiaodj() ;
- }
- }
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class shubiaodj extends JFrame implements ActionListener {
JTextField tf;
int a;
shubiaodj(){
JFrame jf = new JFrame("鼠标点击速度大比拼");//软件名称
jf.setVisible(true);
jf.setSize(250, 200);//设置窗口体积
jf.setLocationRelativeTo(null);
JLabel jl=new JLabel("点击次数");//标签
tf= new JTextField(10);// 文本框
JButton but= new JButton("请连续点击");//Button按钮
but.addActionListener(this);
jf.add(jl);
jf.add(tf);
jf.add(but);
jf.setLayout(new FlowLayout());
}
public void actionPerformed(ActionEvent e){
String s = e.getActionCommand() ;
if(s.equals("请连续点击"))
tf.setText(""+a++);
}
public static void main(String[] args) {
new shubiaodj() ;
}
}