无法在向导页面中重绘 SWT Composite

Unable to redraw SWT Composite in a Wizard Page

我有一个组合,它有 3 个 UI 控件 - SWT 组、SWT TabFolder 和一个具有标签和 link 的子组合。在某些用例中,SWT 组是隐藏的,我希望看不到空白 space 而不是必须重新绘制复合材料并仅显示 SWT TabFolder 和子复合材料,没有任何 space. 我正在使用 composite.layout(true),但是当它被隐藏时,SWT 组仍然是空白的 space。 谁能帮我解决这个问题

TestComposite extends Composite{
   private Label childlabel;    
   private Group group;
   private TabFolder tabFolder;
   private Button button;

    TestComposite(Compossite parent){
       super(parent, SWT.NONE);
       setLayout(new GridLayout(1, true));
       setFont(parent.getFont());
       setBackground(parent.getBackground());
       GridDataFactory.fillDefaults().grab(true, true).applyTo(this);
       createControl();
    }

    public void createControl() {

    this.group = new Group(this, SWT.SHADOW_IN);       
    this.group.setSize(this.getDisplay().getActiveShell().getSize());        
    this.button = new Button(this.group, SWT.PUSH); 
    GridDataFactory.swtDefaults().applyTo(this.button);
         
    this.tabFolder = new TabFolder(this, SWT.TOP);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, 
    true).applyTo(this.tabFolder);

    Composite childComposite = new Composite(this, SWT.NONE);
    childComposite .setLayout(new GridLayout(2, false));
    GridDataFactory.swtDefaults().grab(true, false).align(SWT.LEFT, 
    SWT.TOP).applyTo(childComposite );
    this.childLabel = new Label(childComposite, SWT.NONE);
    GridDataFactory.swtDefaults().grab(true, false).applyTo(childlabel);

    setInput(abc);
    enableVisibilityOfGroup(false);
}

public void enableVisibilityOfGroup(Boolean visible){
    this.group.setVisible(visible);
    // this shoudl redraw the UI and shown only tabFolder and label in the
    // whole wizard page, but there is blank space in place of group
    this.layout(true);
}
    

}

Group

上设置 GridData
GridDataFactory.swtDefaults().applyTo(this.group);

使用GridData.exclude到exclude/include布局中的组:

public void enableVisibilityOfGroup(boolean visible) {
    this.group.setVisible(visible);

    GridData gridData = (GridData)this.group.getLayoutData();
    gridData.exclude = !visible;

    this.layout(true);
}