我想在 Scout 类中使用 Timer 来更改 Scout 元素的 UI。
例如:我有一些标签,我想在一段时间后更改值:
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
myLabel.setValue("some value")
}
}, 1000 * 4);
这给了我错误:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: queueing rwt runnable from outside scout thread
女巫我理解,因为您不应该在其线程之外更改 UI。但是现在我无法返回 UI 线程,因为它不是 SWT 线程也不是 SWING 线程。(Scout UI 是两者的包装)
如何在 Scout 中运行 Timer,或者如何在 Scout 中获取 UI 线程?
马尔科