2

当我们使用 SWT 在 eclipse 插件开发中按下向导标题栏中的最大化按钮时,宽度Composite正在发生变化。

我该如何克服这个问题?

注意:我没有使用KFaceWizardDialogShellDisplay。我只在使用Composite,我的主要课程正在实施IWizard

public void createControl(Composite parent) 
{
    // TODO Auto-generated method stub
    composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout());  

    /*GridLayout gridLayout = new GridLayout();
    gridLayout.verticalSpacing = 10;
    //gridLayout.makeColumnsEqualWidth = true;
    //gridLayout.numColumns = 2;*/  

    Composite operationsListComposite = new Composite(composite, SWT.NONE);
    operationsListComposite.setLayout(new GridLayout(2,false));
    operationsListComposite.setLayoutData(new GridData(
            GridData.FILL_HORIZONTAL));     

    Label operationLabel = new Label(operationsListComposite, SWT.NONE);
    operationLabel.setText("");

    //Label emptyLabel = new Label(operationsListComposite, SWT.NONE);
    //emptyLabel.setText("");

    Label adapterLabel = new Label(operationsListComposite, SWT.NONE);
    adapterLabel.setText("");       

    fileGroupsList = new List(operationsListComposite,SWT.BORDER
            | SWT.V_SCROLL | SWT.H_SCROLL);
    fileGroupsList.add("JSP1");
    fileGroupsList.add("JSP2");
    fileGroupsList.add("JSP3");
    fileGroupsList.add("JSP4");
    fileGroupsList.addListener(SWT.Selection, this);

    //operationsTree = new Tree(operationsListComposite,SWT.BORDER
    //      | SWT.V_SCROLL | SWT.H_SCROLL);
    //operationsTree.addListener(SWT.Selection, this);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    data.heightHint = 150;
    data.widthHint=100;
    //operationsTree.setLayoutData(data);
    fileGroupsList.setLayoutData(data);


    //filesList = new List(operationsListComposite,SWT.BORDER
    //      | SWT.V_SCROLL | SWT.H_SCROLL);
    Composite css1Composite = new Composite(operationsListComposite, SWT.BORDER);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
    //gridData.horizontalSpan= 2;
    gridData.grabExcessHorizontalSpace = true;
    css1Composite.setLayoutData(gridData);
    GridLayout grpL = new GridLayout(3,false);
    grpL.verticalSpacing=0;
    css1Composite.setLayout(grpL);
    }}
4

1 回答 1

2
operationsListComposite.setLayoutData(new GridData(
            GridData.FILL_HORIZONTAL));     

告诉 SWT 您希望复合材料填充所有空间,这就是在调整大小时扩展的原因。

GridData data = new GridData(SWT.BEGINNING, SWT.TOP, false, false);
data.widthHint = 100;
operationsList.setLayoutData(data);

停止合成以调整大小并给出建议的大小 - 100。

编辑:您可能不需要宽度提示。

于 2013-09-11T12:42:48.047 回答