0

Good evening. I created SWT application, which contains shell with two elements: ExpandBar and Button. At application start all items of ExpandBar are expanded and Button is under ExpandBar. I want to do the following: collapse all ExpandBar's items by Button's click and redraw composite after this action.

I expect, that button after redraw occured right under collapsed ExpandBar, but Button thinks another way and doesn't change its place. One more interesting thing is that after second click on Button all elements behaviour become correct.

My source code looks like this:

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();
    } 
}); 

How to redraw the composite after the first click?

Baldrick
  • 23,882
  • 6
  • 74
  • 79

0 Answers0