5
我是SWT的新手。我正在研究的这个项目有一个主要的复合材料,上面有3个孩子。上部组合由按钮组成,中间组合用于显示内容,下部组合用于其他目的。发生什么事情是,当我点击上层复合中的一个按钮时,它必须触发中间复合中的内容更改。 这就是我用来做这个如何在单击按钮后重新绘制swt复合图案以更改该复合图案的内容
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);
}
现在的问题是后,我按一下按钮,上面的代码的代码被执行,似乎没有发生,直到我调整界面,然后在中间复合材料中的含量会出现。
我正面临类似的问题。我有复合材料,它有一些文本字段和按钮。我想在点击一个按钮时添加一个新的复选框。它正在增加,但我只能看到调整UI的大小。 我试着在Composite上调用布局..但是这并没有做任何事...你能告诉我你是如何解决这个问题的。 – 2016-08-25 07:16:39