不好意思,主页或许出了点小问题!!!
真是多谢啊,现在好象是可以运行了!!!
不过好象又有点小问题,等我找到再跟大家讨论讨论哦!!!
代码更改如下:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
class FileName implements FilenameFilter //
{
  String str=null;
  FileName(String s)
  {
    str=" . "+s;
  }
  public boolean accept(File dir,String name)
  {
    return name.endsWith(str);
  }
}
//试题显示区 a1
//消息区 a2
//提交该题答案 a3
//读取下一题 a4
//查看分数 a5
//读取试题 a6
//是否关闭计时器 a7
//是否暂停计时器 a8
//暂停或继续计时a9
//当前目录 b1
public class TestArea extends JPanel implements ActionListener,ItemListener,Runnable
{
  Choice list=null; //
  JTextArea a1=null,a2=null;
  JCheckBox box[];
  JButton a3,a4,a5; //
  ReadTestquestion a6=null; //
  JLabel welcomeLabel=null; //
  Thread countTime=null; //
  long time=0; //
  JTextField timeShow=null; //
  boolean a7=false,a8=false;
  JButton a9=null;
  public TestArea()
  {
    list=new Choice();
    //
    String b1=System.getProperty("user.dir");
    File dir=new File(b1);
    FileName fileTxt=new FileName("txt");
    String fileName[]=dir.list(fileTxt); //
    for(int i=0;i<fileName.length;i++)
    {
      list.add(fileName[i]);
    }
    a1=new JTextArea(15,12);
    a1.setLineWrap(true); //
    a1.setWrapStyleWord(true); //
    a1.setFont(new Font("TimesRoman",Font.PLAIN,14));
    a1.setForeground(Color.blue);
    a2=new JTextArea(8,8);
    a2.setForeground(Color.blue);
    a2.setLineWrap(true);
    a2.setWrapStyleWord(true);
    countTime=new Thread(this); //
    String s[]={"A","B","C","D"};
    box=new JCheckBox[11];
    for(int i=0;i<11;i++)
    {
      box[i]=new JCheckBox(s[i]);
    }
    a9=new JButton("暂停计时");
    a9.addActionListener(this);
    a3=new JButton("提交该题答案");
    a3.setForeground(Color.blue);
    a4=new JButton("读取第一题");
    a4.setForeground(Color.blue);
    a5=new JButton("查看分数");
    a5.setForeground(Color.blue);
    a3.setEnabled(false);
    a3.addActionListener(this);
    a4.addActionListener(this);
    a5.addActionListener(this);
    list.addItemListener(this);
    a6=new ReadTestquestion();
    JPanel pAddbox=new JPanel();
    for(int i=0;i<11;i++)
    {
      pAddbox.add(box[i]);
    }
    Box boxH1=Box.createVerticalBox(),boxH2=Box.createVerticalBox(),baseBox=Box.createHorizontalBox(); //
    boxH1.add(new JLabel("选择试题文件"));
    boxH1.add(list);
    boxH1.add(new JScrollPane());
    boxH1.add(a5);
    timeShow=new JTextField(20);
    timeShow.setHorizontalAlignment(SwingConstants.RIGHT); //
    timeShow.setEditable(false);
    JPanel p1=new JPanel();
    p1.add(new JLabel("剩余时间:"));
    p1.add(timeShow); //
    p1.add(a9);
    boxH1.add(p1);
    boxH2.add(new JLabel("试题内容:"));
    boxH2.add(new JScrollPane(a1));
    JPanel p2=new JPanel();
    p2.add(pAddbox); //
    p2.add(a3);
    p2.add(a4);
    boxH2.add(p2);
    baseBox.add(boxH1);
    baseBox.add(boxH2);
    setLayout(new BorderLayout());
    add(baseBox,BorderLayout.CENTER);
    welcomeLabel=new JLabel("欢迎考试,提高英语水平",JLabel.CENTER);
    welcomeLabel.setFont(new Font("隶书",Font.PLAIN,24));
    welcomeLabel.setForeground(Color.blue);
    add(welcomeLabel,BorderLayout.NORTH);
  }
  public void itemStateChanged(ItemEvent e)
  {
    timeShow.setText(null);
    a7=false;
    a8=false;
    a9.setText("暂停计时");
    String name=(String)list.getSelectedItem();
    a6.setFilename(name);
    a6.set完成考试(false);
    time=a6.getTime(); //
    if(countTime.isAlive()) //
    {
      a7=true;
      countTime.interrupt();
    }
    countTime=new Thread(this);
    a2.setText(null);
    a1.setText(null);
    a4.setText("读取下一题");
    a3.setEnabled(false);
    a4.setEnabled(true);
    welcomeLabel.setText("欢迎考试,你选择的试题:"+a6.getFilename());
  }
  public void actionPerformed(ActionEvent e)
  {
    if(e.getSource()==a4);
    {
      a4.setText("读取下一题");
      a3.setEnabled(true);
      String contentTest=a6.getTestContent();
      a1.setText(contentTest);
      a2.setText(null);
      a4.setEnabled(false);
      try{
        countTime.start(); //
      }
      catch(Exception event)
      {
        //
      }
    }
    if(e.getSource()==a3)
    {
      a4.setEnabled(true);
      a3.setEnabled(false);
      String answer="?";
      for(int i=0;i<11;i++)
      {
        if(box[i].isSelected())
        {
          answer=box[i].getText();
          box[i].setSelected(false);
          break;
        }
      }
      a6.setSelection(answer);
    }
    if(e.getSource()==a5)
    {
      int score=a6.getScore();
      String messages=a6.getMessages();
      a2.setText("分数:"+score+"\n"+messages);
    }
    if(e.getSource()==a9)
    {
      if(a8==false)
      {
        a9.setText("继续计时");
        a8=true; //
      }
      else if(a8==true)
      {
        a9.setText("暂停计时");
        a8=false;
        countTime.interrupt(); //
      }
    }
  }
  public synchronized void run() //
  {
    while(true)
    {
      if(time<=0)
      {
        a7=true;
        countTime.interrupt(); //
        a3.setEnabled(false); //
        a4.setEnabled(false); //
        timeShow.setText("考试时间用尽,考试结束");
      }
      else if(a6.get完成考试())
      {
        a7=true;
        timeShow.setText("考试结果:分数*剩余时间(秒)="+1.0*a6.getScore()*(time/1000));
        countTime.interrupt(); //
        a3.setEnabled(false); //
        a4.setEnabled(false); //
      }
      else if(time>=1)
      {
        time=time-1000;
        long leftTime=time/1000; //
        long leftHour=leftTime/3600; //
        long leftMinute=(leftTime-leftHour*3600)/60; //
        long leftSecond=leftTime%60; //
        timeShow.setText(""+leftHour+" 小 时 "+leftMinute+" 分 "+leftSecond+" 秒 ");
      }
      try
      {
        Thread.sleep(1000); //
      }
      catch(InterruptedException ee)
      {
        if(a7==true)
        return; //
      }
      while(a8==true)
      {
        try
        {
          wait(); //
        }
        catch(InterruptedException ee)
        {
          if(a8==false)
          {
            notifyAll(); //
          }
        }
      }
    }
  }
}