public void actionPerformed(ActionEvent e)
{
while(....)
{
n = (int)(Math.random() * name.length);
tf.setText("" + name[n]);
  }
}
actionPerformed里千万不能放while,for,要开个新线程.public void actionPerformed(ActionEvent e)
{
    (new Thread(){
        public void run(){
            while(....)
   {
    n = (int)(Math.random() * name.length);
    tf.setText("" + name[n]);
    }
        }
    }).start();
}

解决方案 »

  1.   

    to dyhml(VirusCamp) :你用线程的方法,好像还是不行呀,我用了这种方法,但停止键还是没有反应,而且显示也不连贯了,中间有停顿的现象出现
      

  2.   

    while(....){
        n = (int)(Math.random() * name.length);
        tf.setText("" + name[n]);
        try{
            Thread.sleep(100);
        }catch(InterruptedException e){}
    }
    试试?