第十三周作业第一题
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame implements ActionListener{
JLabel bq1;
JTextField wbk;
JButton an;
int i=0;
Test(){
bq1 = new JLabel("点击次数");
wbk = new JTextField(10);
an = new JButton("请连续点击");
an.addActionListener(this);
this.add(bq1);
this.add(wbk);
this.add(an);
this.setLayout(new FlowLayout());
this.setTitle("鼠标点击数都大比拼");
this.setSize(600,150);
this.setLocation(200, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame implements ActionListener{
JLabel bq1;
JTextField wbk;
JButton an;
int i=0;
Test(){
bq1 = new JLabel("点击次数");
wbk = new JTextField(10);
an = new JButton("请连续点击");
an.addActionListener(this);
this.add(bq1);
this.add(wbk);
this.add(an);
this.setLayout(new FlowLayout());
this.setTitle("鼠标点击数都大比拼");
this.setSize(600,150);
this.setLocation(200, 300);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new Test();
}
public void actionPerformed(ActionEvent e) {
i++;
wbk.setText(""+i);
}
}
i++;
wbk.setText(""+i);
}
}