SWT

来源:互联网 发布:软件许可协议模板 编辑:程序博客网 时间:2024/05/16 04:57

How to update a GUI from another thread in Java

Use Display.asyncExec or Display.syncExec, depending on your needs.

For example, another thread might call this method to safely update a label:

 

 

private static void doUpdate(final Display display, final Label target,      final String value) {    display.asyncExec(new Runnable() {      @Override      public void run() {        if (!target.isDisposed()) {          target.setText(value);          target.getParent().layout();        }      }    });  }

 

0 0