例如界面上有一个Text,我另一个线程从别的地方得到数据,想在界面上更新text控件的值,

解决方案 »

  1.   

    在run方法中更新
    class TestThread implements Runnable {
      JTextArea textArea;
      public TestThread (JTextArea textArea) {
        this.textArea = textArea;
      }  public void run() {
       ...
       textArea.append("xxx");   // 此处更新
      }
    }
      

  2.   

    textArea不是线程类的成员啊。
    访问总是得到
    Invalid thread access
      

  3.   

    首先要通过构造函数把textArea传进来,还要声明一个textArea获取他的引用。
      

  4.   

    $ zz╭ ╮╭ ﹌╮.       $
    $   z(o-.-o)(o-.-o) .      $
    $ ┏~﹊︸ ̄~﹊︸ ̄~┓      $
    $ IT者-IT开发者的网站--    $
    $ 10万篇技术资料--天天更新 $
    $ -----www.itzhe.cn-----   $