打字训练测试软件Java课程设计.docxVIP

  • 11
  • 0
  • 约5.72千字
  • 约 10页
  • 2023-10-07 发布于上海
  • 举报
《程序设计实践》 题目: 打字训练测试软件 学校:陕西工业学院学院:信息学院 班级:信管 12-2 学号: 201 姓名:刘克豪 2014 年 11 月 09 日 基础类、IO 流与异常处理程序设计 一、实践要求 掌握 Java 常用基础类 API。 掌握输入输出流常用类 API。 二、实践要求 利用 Java 常用基础类 API、输入输出流常用类 API、Java 异常处理等完成所选项目的程序设计。 三、项目需求 所选项目名称:打字训练测试软件 四、项目设计方案 EnglishGame 类:主要构造都在这里完成。MyKey 类:是该程序的一个内部类。 EnglishGame 作为主函数的入口。调用 actionPerformed 类的方法实现事件监听器。当发生点击事件时就会弹出输入框,开始英文打字功能。从而达到打字训练测试的目的。 五、核心算法详细设计 1 . public void actionPerformed(ActionEvent e) {} public void keyReleased(KeyEvent arg0) {} public static void main(String[] args) {} public JPanel creatMenu() {} 六、完整源码 package shiyansan; import public class EnglishGame implements ActionListener { private static JFrame f = new JFrame(英文打字游戏); private static Container con = f.getContentPane(); JPanel mainPanel,panel0,panel1,panel2,panel3,panel4,panel5,panel6,panel7; JButton button1,button2,button3,button4,button,button5,button6; JTextPane tp1,tp2; FileReader fr; File frr; Date date1,date2; int num,len1,len2,count; long time; double rightrate; char[] ch; public void actionPerformed(ActionEvent e) { // TODO Auto-generated method stub String cmd = e.getActionCommand(); date1=new Date(); if (cmd.equals(6.退出)) { System.exit(0); } else if(cmd.equals(返回)) { } else { JFrame f1 = new JFrame( 英 文 打 字 游 戏 ); f1.setSize(350, 750); f1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container con1 = f1.getContentPane(); panel0 = new JPanel(); panel1 = new JPanel(); panel2 = new JPanel(); panel3 = new JPanel(); panel4 = new JPanel(); panel6 = new JPanel(); panel7 = new JPanel(); tp1=new JTextPane(); tp1.setBackground(Color.pink); Font size=new Font(ad,Font.BOLD,20); tp1.setFont(size); tp1.setPreferredSize(new Dimension(300,300)); tp1.setForeground(Color.white); tp2=new JTextPane(); tp2.setBackground(Color.lightGray); tp2.setFont(size); tp2.setPreferredSize(new Dimension(300,300)); try { if (cmd.equals(1.文本 1)) { fr=new FileReader(D:\\文本 1.txt); frr=new File(D:\\文本 1.txt); num=(int)frr.length(); ch=new char[num]; while(fr.read(ch)!=-1) { String str=new Str

文档评论(0)

1亿VIP精品文档

相关文档