转自:http://lggege.iteye.com/blog/232964
public class XmindTest {
public static void main(String[] args) {
Display.getDefault();
ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(null);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("任务", 100);
for (int i = 0; i < 10 && !monitor.isCanceled(); i++) {
Thread.sleep(500);
monitor.worked(10);
monitor.subTask("第" + i + "个任务");
}
monitor.done();
}
};
try {
progressDialog.run(true,/*是否开辟另外一个线程*/
true,/*是否可执行取消操作的线程*/
runnable/*线程所执行的具体代码*/
);
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}