⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 words.java

📁 200多个自己编的java程序,大家可以学一下.
💻 JAVA
字号:
/* * 英语单词填空.java * * Created on 2004年9月25日, 上午11:01 *//** * * @author  litertiger */import java.util.*;import java.awt.*;import java.awt.event.*;import java.io.*;public class words extends Frame implements ItemListener, ActionListener{    String str[]=new String[7];    String s;    FileReader file;    BufferedReader in;    Button button_start;    Checkbox box[];    TextField text1,text2;    int fenshu=0;    CheckboxGroup age=new CheckboxGroup();        /** Creates a new instance of 英语单词填空 */    public words() {        super("英语单词学习");        text1=new TextField(10);        text2=new TextField(70);        button_start=new Button("重新练习");        button_start.addActionListener(this);        try{            file=new FileReader("English.txt");            in =new BufferedReader(file);                    }        catch(FileNotFoundException e)        {            System.out.println("没有找到文件");        }        catch(IOException e)        {                    }        setBounds(100,100,400,320);        setVisible(true);        setLayout(new GridLayout(5,1));        setBackground(Color.pink);        Panel p1=new Panel(),p2=new Panel(),p3=new Panel(),p4=new Panel();        p2.setLayout(new GridLayout(2,1));        p3.setLayout(new GridLayout(5,1));        p1.add(new Label("你的 得分 :"));        p1.add(text1);        p2.add(button_start);        box=new Checkbox[6];        for(int i=0;i<=4;i++)        {            box[i]=new Checkbox("",false,age);            box[i].addItemListener(this);        }        p3.add(new Label("选择答案"));        for(int i=1;i<=4;i++)        {            p3.add(box[i]);            add(p1);            add(p2);            add(new Label());            add(p3);            add(p4);            addWindowListener(new WindowAdapter()            {                                public void windowClosing(WindowEvent w)                {                    setVisible(false);                    System.exit(0);                }            });            reading();        }                                    }    public void reading()    {            int i=0;        try{                s=in.readLine();        if(!(s.startsWith("endend"))){            StringTokenizer tokenizer=new StringTokenizer(s,"#");            while(tokenizer.hasMoreTokens())            {                str[i]=tokenizer.nextToken();                i++;                            }            text1.setText(str[0]);            for(int j=1;j<=4;j++)            {                box[j].setLabel(str[j]);            }        }        else if(s.startsWith("endend"))        {            text2.setText("学习完毕");                        for(int j=1;j<=4;j++)            {            box[j].setLabel("end");            in.close();            file.close();                        }        }                }        catch(IOException e)        {                    }    }        public void actionPerformed(ActionEvent e) {        if(e.getSource()==button_start)        {        file=null;        in=null;        fenshu=0;        text2.setText("得分:"+fenshu);        try{            file=new FileReader("English.txt");            in=new BufferedReader(file);                    }        catch(FileNotFoundException ex)        {}        catch(IOException IOe)        {}        reading();                }    }        public void itemStateChanged(ItemEvent e) {        for(int j=1;j<=4;j++)        {            if(box[j].getLabel().equals(str[5])&&box[j].getState())            {                fenshu++;                text2.setText("得分 :"+fenshu);            }                   }         reading();    }        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -