0

我试图从来自 TreeViewer 的数据水平填充复合材料,但没有成功。如果您有任何建议,我将不胜感激。

这是我正在使用的代码:

 private Composite composite;
 private ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);

    composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
    composite.setLayout(createNoMarginLayout(1, false));

    scrolledComposite.setContent(composite);

    compositeNdal = new Composite(composite, SWT.NONE);
    compositeNdal.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
    compositeNdal.setLayout(createNoMarginLayout(1, true));
    compositeNdal.setVisible(true);



    treeViewerNdalEditor = new TreeViewer(compositeNdal,SWT.BORDER|SWT.FILL);
    /* (computing the tree part goes here)  */

 public static GridLayout createNoMarginLayout(int numColumns, boolean makeColumnsEqualWidth) {
        GridLayout layout = new GridLayout(numColumns, makeColumnsEqualWidth);
        layout.verticalSpacing = 0;
        layout.horizontalSpacing = 0;
        layout.marginTop = 0;
        layout.marginBottom = 0;
        layout.marginLeft = 0;
        layout.marginRight = 0;
        layout.marginWidth = 0;
        layout.marginHeight = 0;
        return layout;
    }
4

1 回答 1

0

您必须在树上设置布局数据以告诉父复合布局如何处理树:

treeViewerNdalEditor.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
于 2014-01-31T11:32:49.530 回答