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