SWT

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

 

你可能感兴趣的:(SWT)