- 论坛徽章:
- 0
|
SWT widget is not accessible out of the SWT main thread. we must play some trick here.
example:
class LocationControl extends Thread {
private CustomLocation location;
public void setLocation(CustomLocation location) {
this.location=location;
}
public void run() {
while ( true ) {
location.x=location.x+2;
try {
sleep(100);
} catch ( Exception e ) {}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
shell.redraw();
}
});
}
}
}
and in the main Thread , we can just start the Thread, the shell
should be redrawed every 100 ms.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4241/showart_117746.html |
|