ProgressBar,进度条,是ProgressIndicator的简化版本。大多数情况下推荐使用ProgressIndicator。如果你决定直接使用ProgressBar,需要手动改变此bar的外观。如下
//Style can be SMOOTH, HORIZONTAL, or VERTICAL
ProgressBar bar = new ProgressBar(parent, SWT.SMOOTH);
bar.setBounds(10, 10, 200, 32);
bar.setMaximum(100);
...
for(int i = 0; i < 10; i++) {
//Take care to only update the display from its
//own thread
Display.getCurrent().asyncExec(new Runnable() {
public void run() {
//Update how much of the bar should be filled in
bar.setSelection((int)(bar.getMaximum() * (i+1) / 10));
}
});
}
setSelection()causes the widget to be updated every time.This behavior is unlike that of ProgressIndicator or ProgressMonitorDialog,which will update the display only if it has changed by an amount that will be visible to the end user.
posted on 2006-04-10 17:56
JOO 阅读(405)
评论(0) 编辑 收藏 所属分类:
SWT & JFace IN ACTION