2
我是SWT的总noob,刚开始,但我以前使用过Swing等GUI框架。如何强制重绘SWT中的隐形组内容?
我有一个复合包含一个组和一个按钮。该组最初设置为不可见(使用group.setVisible(false)),并在单击该按钮时设置为可见。这会启动一个执行一些计算的线程,用进度更新组内的标签(类型是手动进度条,这是客户想要的:))。
无论如何,出于某种原因,该组只出现在线程完成运行后,无论我用什么(尝试调用this.pack()),我似乎都无法显示它。 layout(),this.getShell()。layout(),重绘()在路径中的各种控件 - 什么都不)。
下面是如何创建组:
statusGroup = new Group(this, SWT.SHADOW_NONE);
statusGroup.setLayout(null);
statusGroup.setVisible(false);
percentCompleteLabel = new Label(statusGroup, SWT.NONE);
percentCompleteLabel.setText("0% complete");
这里是我如何从按钮的SelectionListener中更新它:
this.statusGroup.setVisible(true);
this.statusGroup.pack(true);
this.statusGroup.layout();
this.getShell().layout();
myThreadStartupCode(); // psuedo
while (!workIsDone) // psuedo
{
final int progress = myProgressCalcMethod(); // psuedo
percentCompleteLabel.setText(progress + "% complete");
percentCompleteLabel.pack(true);
this.layout();
this.redraw();
Thread.sleep(100);
}
任何线索,将不胜感激。