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();
}