0
我有一個Composite
的子類,創建了N個組合框,其中N由輸入定義。所以當用戶進行更改時,組合框的數量可能會發生變化。目前,這不會發生。我試着做這兩種方式:swt - 重新創建複合
// On event, straight reconstruct, no change to number of dropdowns
myComp = new MyComposite(parent, SWT.NONE, newNum);
// On event, dispose and reconstruct, this completely removes my composite from the gui
myComp.dispose();
myComp = new MyComposite(parent, SWT.NONE, newNum);
這裏是我的綜合類:
public MyComposite(Composite parent, int num) {
super(parent, SWT.BORDER);
this.setText("MY Composite");
this.setLayout(new GridLayout(1, true));
this.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
combos = new HashMap<>();
for(int i = 0; i < num; i++) {
combos.put(i, new Combo(this, SWT.NONE));
}
}
是否有其他/更好的方式來做到這一點?