改成下面这段:
class StartL implements ActionListener {
   public void actionPerformed(ActionEvent e) {
      for(int i = 1; i <= 5; i++) {
try {
   Thread.sleep(1000);
} catch(InterruptedException ex) {
   System.err.println("Interrupted");
}
t.setText(t.getText()+Integer.toString(i));
      }
   }
}

解决方案 »

  1.   

    可能是你Sleep的Thread不是你要的,
    你继承Thread类试试。——————————————————
    个人想法,没实验过,你试试
    ——————————————————
      

  2.   

    主线程sleep了,当然不会刷新了
    应该在另外一个线程中设置刷新才可以
      

  3.   

    setText
    public void setText(String t)Sets the text of this TextComponent to the specified text. If the text is null or empty, has the effect of simply deleting the old text. When text has been inserted, the resulting caret location is determined by the implementation of the caret class. 
    This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information. 
      

  4.   

    1、我刚从C/S的开发工具转到Java开发平台上来,在以前的开发工具里,文本框text属性的改变都是马上可以反映出来的,是不是我某种惯性思维需要改变
    2、刚接触线程,有许多概念还不是很清楚,按我的理解,执行Thread.sleep(1000);语句的时候线程sleep了,那执行t.setText(Integer.toString(i));语句的瞬间,主线程应该是active的吧。不知我的理解是否正确?
    3、不知Thread safe是个什么概念,哪位大虾能帮忙解释几句?