こんばんは。ExpandBar と Button の 2 つの要素を持つシェルを含む SWT アプリケーションを作成しました。アプリケーションの開始時に、ExpandBar のすべての項目が展開され、Button は ExpandBar の下にあります。私は次のことをしたい: ボタンのクリックですべての ExpandBar の項目を折りたたみ、このアクションの後にコンポジットを再描画します。
私は、再描画後のボタンが折りたたまれた ExpandBar のすぐ下に発生したことを期待していますが、Button は別の方法を考え、その場所を変更しません。もう 1 つの興味深い点は、ボタンを 2 回クリックすると、すべての要素の動作が正しくなることです。
私のソースコードは次のようになります。
final ExpandBar bar = new ExpandBar (shell, SWT.NONE);
bar.setLayoutData(new RowData());
Button redraw = new Button(shell,SWT.PUSH);
redraw.setText("redraw");
redraw.setLayoutData(new RowData());
redraw.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
shell.layout(true,true);
Display.getCurrent().update();
for (ExpandItem item: bar.getItems())
{
item.setExpanded(false);
}
bar.redraw();
bar.update();
bar.layout(true,true);
shell.layout(true,true);
Display.getCurrent().update();
}
});
最初のクリック後にコンポジットを再描画する方法は?