【发布时间】:2014-06-20 20:21:11
【问题描述】:
我是 SWT 的新手。我正在做的项目有一个主复合材料,上面有 3 个子复合材料。上组合由按钮组成,中组合用于显示内容,下组合用于其他用途。必须发生的是,当我单击上部复合材料中的按钮时,它必须触发中间复合材料中的内容更改。 这是我用来做这个的代码
public void widgetSelected(SelectionEvent e) {
/* Retrieve the contents that are currently in middle composite*/
Composite currentCenterComposite = EMWindow.getCenterCompsiteState();
/* Retrieve the main composite*/
Composite outerComposite=EMWindow.getOuterCompsiteState();
if ((currentCenterComposite != null) && (!currentCenterComposite.isDisposed())) {
/* Remove children that are already laid out */
Object[] children = currentCenterComposite.getChildren ();
for (int i = 0; i < children.length; i++) {
((Composite)children[i]).dispose();
}
}
currentCenterComposite = new CenterComp(currentCenterComposite);
GridData gd_centerComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_centerComposite.minimumHeight = 50;
currentCenterComposite.setLayoutData(gd_centerComposite);
currentCenterComposite.layout(true);
//currentOuterComposite.layout();
outerComposite.layout(true);
}
现在的问题是在我点击按钮并执行上面的代码之后,直到我调整 GUI 大小之前似乎什么都没有发生,然后中间合成中的内容就会出现。
【问题讨论】:
-
我面临着类似的问题。我有复合材料,其中有一些文本字段和按钮。我想在单击按钮时添加一个新的复选框字段。它正在被添加,但我只能在调整 UI 大小时看到。我尝试在 Composite 上调用 layout ..但这并没有做任何事情...你能告诉我你是如何解决这个问题的吗?