修改图形界面签到程序

代码有点坑!!!

实现功能不多!!!

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public  class Tu extends Frame implements ActionListener {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * @param args
	 * @throws FileNotFoundException 
	 */
	  static String[][] stringArray ;
	  static Frame f = new Frame("图形界面签到程序");
	  static Label lb = new Label("学生姓名");
	  static TextField tf = new TextField(10);
	  static Button b1 = new Button("到");
	  static Button b2 = new Button("缺德");
	  static Label b = new Label("考勤结果");
	  static TextArea ta = new TextArea(15,30);
	  static String t = "缺席名单:";
	  static int count2 = 0;
	  static int count = 0;
	  
		 // TODO Auto-generated method stub
		@SuppressWarnings("resource")
		public static void main(String[] args) throws FileNotFoundException {
			 File fr=new File("d:\\users","wl121.txt");
			Scanner sc = new Scanner(fr);
			 Scanner st = new Scanner(fr);
			 
			  while (sc.hasNext()) {//确定人数  
		           count++;  
		            sc.nextLine();  
		        }
	 		  stringArray = new String[count][2]; 
					for (int a = 0; a < count ; a++) {//读入数组  
			        	stringArray[a][0] = st .nextLine();
			         }  
					sc.close(); 
					st.close();
					//tf.setText(strName);
					tf.setText(stringArray[count2][0]);//
				    Tu tu = new Tu();
					tu.setLayout(new FlowLayout(FlowLayout.LEFT,20,40));
					tu.add(lb);
					tu.add(tf);
					tu.add(b1);
					tu.add(b2);
					tu.add(b);
					tu.add(ta);
					tu.setVisible(true);
					tu.setSize(350,300);
			 		b1.addActionListener(tu);
			 		b2.addActionListener(tu);
			 		ta.setEditable(true); 		 	
					
    }	
		public  void actionPerformed(ActionEvent e) {
	 		if(e.getSource()==b1 ){
	 			tf.setText(stringArray[count2][0]);//
	 			            count2++;//
	 		}
	 		else if(e.getSource()==b2 ){
	 			    String strAbsent =stringArray[count2][0];//
	 			    ta.setText(t+strAbsent+"    "+"\r\n");
	 		
	 		}
	 		
	          } 
}		


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值