Ниже мой код. Когда кнопка нажата, я меняю список item1 с помощью item1.setcontrol зависит от моего состояния. Composite не освежает, но когда я нажимаю на вкладку Item2 и возвращаюсь к вкладке Item1 ... Список обновляется в зависимости от состояния. Пожалуйста, дайте мне знать Как обновить макет, перейдя в другой элемент табуляции.TabItem не обновляется, когда список tabItem изменился в SWT
final Composite RightComposite = new Composite(paComposite, SWT.NONE);
RightComposite.setLayout(new GridLayout(1, false));
RightComposite.setLayoutData(new GridData(SWT.FILL, GridData.FILL, true, true));
Composite findComposite = new Composite(RightComposite, SWT.NONE);
findComposite.setLayout(new GridLayout(2, true));
findComposite.setLayoutData(new GridData(SWT.FILL, GridData.FILL, true, false));
txt = new Text(findComposite, SWT.BORDER | SWT.WRAP | SWT.SINGLE);
txt.setLayoutData(new GridData(SWT.FILL, GridData.FILL, true, false));
txt.addListener(SWT.Verify, new Listener()
{
@Override
public void handleEvent(final Event e)
{
newString = ((Text) e.widget).getText();
}
});
btn = new Button(findTCComposite, SWT.NONE);
btn.setLayoutData(new GridData(SWT.BEGINNING, GridData.BEGINNING, false, false));
btn.setText("Find button");
final TabFolder tabFolder = new TabFolder(RightComposite, SWT.NONE);
tabFolder.setLayoutData(new GridData(SWT.FILL, GridData.FILL, true, true));
final TabItem item1 = new TabItem(tabFolder, SWT.NONE);
item1.setText("Tab 1 ");
btn.addListener (SWT.Selection, new Listener()
{
public void handleEvent(Event e) {
if(!newString.isEmpty()){
item1.setControl(list1);
}
else
{
item1.setControl(list);
}
}
});
TabItem item2 = new TabItem(tabFolder, SWT.NONE);
Item2.setText("Tab 2");
RightComposite.layout();