第5周作业-打字成绩判断程序GUI

偷了点懒,功能没全部实现

import java.applet.Applet;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class TouchTypeGUI extends Applet implements ActionListener {

	/**
	 * @param args
	 */
	//新建各类组件对象
	JPanel jp = new JPanel();
	JPanel jp1 = new JPanel();
	JLabel jl = new JLabel("打字数目");
	JTextField tf = new JTextField(8);
	JLabel jl1 = new JLabel("打字成绩");
	JTextField tf1 = new JTextField(8);
	JButton jb = new JButton("确定");
	JButton jb1 = new JButton("清除");

	public void init() {
		//初始化组件并添加监听器
		add(jp);
		add(jp1);
		jp.add(jl);
		jp.add(tf);
		jp.add(jl1);
		jp.add(tf1);
		jp1.add(jb);
		jp1.add(jb1);
		tf.addActionListener(this);
		jb.addActionListener(this);
		jb1.addActionListener(this);
		setSize(350, 200);
		setVisible(true);

	}

	// String st = str.toString();
	//

	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		String st = tf.getText();//获取文本框的输入信息
		Integer in = new Integer(st);
		
		if (e.getSource() == jb1) {//清除文本框的显示信息
			tf.setText(null);
			tf1.setText(null);
		}
        
		//对控件的响应
		if (e.getSource() == jb && in <= 15) { // && in < 15

			tf1.setText("不及格!!!");

		} else if (e.getSource() == jb && 15 < in && in <= 30) {
			tf1.setText("合格!!!");

		} else if (e.getSource() == jb && in > 30) {
			tf1.setText("优秀!!!");
		}

	}

}



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值