麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

英文打字練習(xí)

2019-11-18 13:25:23
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

  java寫的英文打字練習(xí)的applet:
  game.java文件:
  -----------------------
  import java.awt.*;
  import java.applet.*;
  import java.io.*;
  import begin;
  
  
  public class game extends Applet{
  String beginLabel=" 開 始 ";
  String quitLabel=" 退 出 ";
  Label label= new Label("B/S英文打字練習(xí)1.0版");
  TextArea context= new TextArea(5,50);
  Button beginButton= new Button(beginLabel);
  Button quitButton= new Button(quitLabel);
  begin bb;
  
  
  public void init(){
  context.setText("Welcome to www.chinabs.net for java technicology.");
  setBackground(Color.white);
  Font f=new Font("SansSerif",Font.BOLD,16);
  label.setFont(f);
  add("North",label);
  add("North",context);
  add("South",beginButton);
  add("South",quitButton);
  }
  
  
  public boolean action(Event evt, Object arg){
  if(arg.equals(beginLabel)){
  if (bb == null)
  bb=new begin(this,context.getText());
  else
  bb.setText(context.getText());
  bb.show();
  return true;
  }
  else if(arg.equals(quitLabel)){
  System.exit(0);
  return true;
  }
  else
  return false;
  }
  }
  
  
  begin.java文件:
  -----------------------
  import java.applet.*;
  import java.awt.*;
  
  
  class Coordinate{
  public int x,y;
  public char name;
  public TextField tt;
  public Coordinate(int x,int y,char na){
  this.x=x;
  this.y=y;
  name= na;
  }
  }
  
  
  public class begin extends Frame{
  public Applet parent;
  public int wrong=0;
  Coordinate number[];
  char key[];
  char gst[];
  String message= "~1234567890-=``QWERTYUIOP[]&&ASDFGHJKL:"```ZXCVBNM,.?`` ";
  String message2="~1234567890-=``qwertyuiop[]&&asdfghjkl:"```zxcvbnm,.?`` ";
  String gamestring="welcome to my homepage.click any key to begin.";
  String quitlabel="返 回";
  String clearlabel="重新開始";
  public String yourrecord= null;
  int gst_length;
  int message_length;
  public TextField tt;
  public int changei=56;
  public int gstch=1;
  public FontMetrics font_m;
  public int string_x=100;
  public Button clear1,close;
  int w= 0,h=0;
  
  
  public begin(Applet parent,String m){
  super("英文打字練習(xí)");
  this.parent= parent;
  this.setBackground(Color.white);
  gamestring= m;
  Panel panel= new Panel();
  tt= new TextField(13);
  clear1= new Button(clearlabel);
  close= new Button(quitlabel);
  add("South",tt);
  panel.setLayout(new FlowLayout());
  panel.add(clear1);
  panel.add(close);
  message_length= message.length();
  key= new char[message_length];
  message.getChars(0,message_length,key,0);
  gst_length= gamestring.length();
  gst= new char[gst_length];
  gamestring.getChars(0,gst_length,gst,0);
  init();
  add("North",panel);
  resize(600,450);
  h= 120;
  setResizable(false);
  show();
  }
  
  
  public void setText(String tt){
  gamestring= tt;
  gst_length= gamestring.length();
  gst= new char[gst_length];
  gamestring.getChars(0,gst_length,gst,0);
  gstch=1;
  wrong=0;
  Graphics g= getGraphics();
  string_x=100;
  repaint();
  }
  
  
  public void init(){
  setBackground(Color.white);
  h=450/3;
  number= new Coordinate[message_length+50];
  for(int I=0;I<14;I++){
  number[I]= new Coordinate(62+I*30,h,key[I]);
  }
  for(int I=0;I<14;I++){
  number[14+I]= new Coordinate(64+I*30,h+30,key[14+I]);
  }
  for(int I=0;I<14;I++){
  number[28+I]= new Coordinate(66+I*30,h+60,key[28+I]);
  }
  for(int I=0;I<14;I++){
  number[42+I]= new Coordinate(68+I*30,h+90,key[42+I]);
  }
  number[56]= new Coordinate(60,130+h,key[56]);
  }
  
  
  public void downboard(int I,Graphics g){
  int index=I;
  if(index!=56){
  g.setColor(Color.lightGray);
  g.fillRect(number[index].x+3,number[index].y+4,23,21);
  for(int i1=0,j=1;i1<3;i1++,j+=2){
  g.setColor(Color.white);
  g.fillRect(number[index].x+28-(i1+1),number[index].y+i1+1,1,28-(2*i1+1)-1);
  g.fillRect(number[index].x+i1,number[index].y+28-(i1+1),28-(2*i1),1);
  g.setColor(Color.gray);
  g.fillRect(number[index].x+i1,number[index].y+i1+1,28-(2*i1),1);
  g.fillRect(number[index].x+i1,number[index].y+i1+1,1,28-(2*i1+1)-1);
  }
  g.setColor(Color.black);
  g.drawChars(key,index,1,number[index].x+12,number[index].y+17);
  }
  else{
  g.setColor(Color.lightGray);
  g.fillRect(number[index].x+53,number[index].y+4,303,21);
  for(int i1=0,j=1;i1<3;i1++,j+=2){
  g.setColor(Color.white);
  g.fillRect(number[index].x+360-(i1+1),number[index].y+i1+1,1,28-(2*i1+1)-1);
  g.fillRect(number[index].x+i1+50,number[index].y+28-(i1+1),310-(2*i1),1);
  g.setColor(Color.gray);
  g.fillRect(number[index].x+i1+50,number[index].y+i1+1,310-(2*i1),1);
  g.fillRect(number[index].x+i1+50,number[index].y+i1+1,1,28-(2*i1+1)-1);
  }
  }
  }
  
  
  public void paintboard(int I,Graphics g){
  int index=I;
  if(index!=56){
  for(int i1=0,j=1;i1<3;i1++,j+=2){
  g.setColor(Color.gray);
  g.fillRect(number[index].x+28-(i1+1),number[index].y+i1+1,1,28-(2*i1+1)-1);
  g.fillRect(number[index].x+i1,number[index].y+28-(i1+1),28-(2*i1),1);
  g.setColor(Color.white);
  g.fillRect(number[index].x+i1,number[index].y+i1+1,28-(2*i1),1);
  g.fillRect(number[index].x+i1,number[index].y+i1+1,1,28-(2*i1+1)-1);
  }
  g.setColor(Color.black);
  g.drawChars(key,index,1,number[index].x+12,number[index].y+17);
  }
  else{
  for(int i1=0,j=1;i1<3;i1++,j+=2){
  g.setColor(Color.gray);
  g.fillRect(number[index].x+360-(i1+1),number[index].y+i1+1,1,28-(2*i1+1)-1);
  g.fillRect(number[index].x+i1+50,number[index].y+28-(i1+1),310-(2*i1),1);
  g.setColor(Color.white);
  g.fillRect(number[index].x+i1+50,number[index].y+i1+1,310-(2*i1),1);
  g.fillRect(number[index].x+i1+50,number[index].y+i1+1,1,28-(2*i1+1)-1);
  }
  }
  }
  
  
  public void paint(Graphics g){
  g.setColor(Color.lightGray);
  g.fillRect(0,0,600,450);
  for(int I=0;I<=56;I++)
  paintboard(I,g);
  g.drawString(gamestring,string_x,100);
  }
  
  
  int ch = gst[gstch];
  Graphics g1=getGraphics();
  record=message2.indexOf(ch);
  if(record!=56){
  g1.setColor(Color.blue);
  g1.fillRect(number[record].x+3,number[record].y+4,22,21);
  g1.setColor(Color.red);
  g1.drawChars(key,record,1,number[record].x+10,number[record].y+18);
  }
  else{
  g1.setColor(Color.blue);
  g1.fillRect(number[record].x+53,number[record].y+4,303,21);
  }
  }
  
  
  public boolean keyDown(Event evt,int key){
  int record2=0;
  Graphics g= getGraphics();
  if(key==8){
  tt.setText("Back Space");
  paintboard(changei,g);
  downboard(13,g);
  changei=13;
  gstch--;
  string_x=string_x-(font_m.charWidth(gst[gstch-1]));
  g.setColor(Color.white);
  g.drawChars(gst,gstch-1,1,string_x,100);
  return true;
  }
  search();
  String aa=Integer.toString(key);
  record2=gamestring.indexOf(key,gstch-1);
  font_m=g.getFontMetrics();
  if(record2==(gstch-1))
  g.setColor(Color.blue);
  else{

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 欧美特级黄色 | 日韩精品中文字幕在线播放 | 免费黄色大片网站 | 久久久久亚洲视频 | 日韩av片在线免费观看 | 国产精品视频海角社区88 | 欧美日在线观看 | 亚洲一区在线国产 | 久久久久久久久日本理论电影 | 国产精品野外av久久久 | 久久久www视频 | 九九热在线视频免费观看 | 欧美精品色精品一区二区三区 | 亚洲精华液久久含羞草 | 91精品国产综合久久婷婷香蕉 | 中文字幕在线免费看 | 亚洲成在人| 中文日韩在线视频 | 久久免费视频5 | av手机在线电影 | 中国女人内谢8xxxxxx在 | 羞羞的| 日韩激情一区二区三区 | 欧美精品一区二区久久 | 7777欧美 | 九九热国产视频 | 在线播放免费人成毛片乱码 | av免费在线观| 成码无人av片在线观看网站 | 成人免费观看49www在线观看 | 在线2区 | 91丨九色丨国产在线观看 | 亚洲日色| 激情视频免费观看 | 最新在线中文字幕 | 91一级毛片 | 成人精品一区二区 | 精品国产99久久久久久宅男i | 婷婷亚洲一区二区三区 | 欧美伦交 | 国产精品一区在线观看 |