0
私はN個のコンボボックスを作成するComposite
のサブクラスを持っています。ここで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));
}
}
はこれを行うには、別の/より良い方法はありますか?