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();
}
{
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();
}
n = (int)(Math.random() * name.length);
tf.setText("" + name[n]);
try{
Thread.sleep(100);
}catch(InterruptedException e){}
}
试试?