How to redraw a swt compound element after clicking a button to change the contents of this composite

I am new to SWT. The project I'm working on has a basic composition with 3 composite composites. The upper composite consists of buttons, and the middle composite is designed to display content, and the lower one is for other purposes. What should happen when I click the button in the top compound element, it should initiate a change in the content in the middle composition. this is the code i use for this

public void widgetSelected(SelectionEvent e) {
    /* Retrieve the contents that are currently in middle composite*/
    Composite currentCenterComposite = EMWindow.getCenterCompsiteState();
    /* Retrieve the main composite*/
    Composite outerComposite=EMWindow.getOuterCompsiteState();
    if ((currentCenterComposite != null) && (!currentCenterComposite.isDisposed())) {
    /* Remove children that are already laid out */
    Object[] children = currentCenterComposite.getChildren (); 
    for (int i = 0; i < children.length; i++) {
 ((Composite)children[i]).dispose();
     }
    }

    currentCenterComposite = new CenterComp(currentCenterComposite);
    GridData gd_centerComposite = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gd_centerComposite.minimumHeight = 50;
    currentCenterComposite.setLayoutData(gd_centerComposite);
    currentCenterComposite.layout(true);
    //currentOuterComposite.layout();
    outerComposite.layout(true);
}

The problem right now, after I click the button and the code has been executed, nothing happens until I change the size of the GUI, then the content will appear in the middle composition.

+5
source share
1

Composite.layout() = " ,

, Layout LayoutData - . LayoutData Composite, . Layout Composite, . currentCenterComposite, layout() .

.

+6

All Articles