第十三周作业第一题

来源:互联网 发布:淘宝直通车在哪开通 编辑:程序博客网 时间:2024/06/04 19:35
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);

 }
 public static void main(String[] args) {
  new Test();
 }
 public void actionPerformed(ActionEvent e) {
  
   i++;
   wbk.setText(""+i);
  }
  
 
}

原创粉丝点击