Java 以滚动形式固定SWT表的大小

Java 以滚动形式固定SWT表的大小,java,scroll,swt,eclipse-rcp,Java,Scroll,Swt,Eclipse Rcp,我对滚动形式的org.eclipse.ui.forms.editor.FormPage的布局有问题。我从中继承了类,并向其中添加了两个部分和几个元素。我想实现底部有3个复合材料,其中第一个获得固定的空间量,第二个和第三个平均分享其余的空间。然而,我得到了以下结果: 以下是部分代码: @Override protected void createFormContent(IManagedForm managedForm) { formToolkit = manage

我对滚动形式的
org.eclipse.ui.forms.editor.FormPage
的布局有问题。我从中继承了类,并向其中添加了两个部分和几个元素。我想实现底部有3个复合材料,其中第一个获得固定的空间量,第二个和第三个平均分享其余的空间。然而,我得到了以下结果:

以下是部分代码:

@Override
    protected void createFormContent(IManagedForm managedForm)
    {
        formToolkit = managedForm.getToolkit();
        ScrolledForm form = managedForm.getForm();

        Composite body = form.getBody();
        GridLayout gridLayout = new GridLayout(1, true);
        gridLayout.horizontalSpacing = 7;
        body.setLayout(gridLayout);
        formToolkit.paintBordersFor(body);

        //skipped

        // Business services left composite
        Composite compositeBSLeft = formToolkit.createComposite(compositeBSMain, SWT.NONE);
        compositeBSLeft.setLayout(new GridLayout(1, false));
        compositeBSLeft.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
        formToolkit.paintBordersFor(compositeBSLeft);
                    // Business services middle composite
        Section sctnBusinessServices = toolkit.createSection(body, Section.TWISTIE | Section.TITLE_BAR);
        sctnBusinessServices.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
        toolkit.paintBordersFor(sctnBusinessServices);
        sctnBusinessServices.setText("Business Services");
        sctnBusinessServices.setExpanded(true);

        //skipped

        Composite compositeBSMidBottom = formToolkit.createComposite(compositeBSMid, SWT.NONE);
        compositeBSMidBottom.setLayout(new GridLayout(1, false));
        compositeBSMidBottom.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        formToolkit.paintBordersFor(compositeBSMidBottom);

        // Permission sets table
        TableViewer permissionSetsTableViewer = new TableViewer(compositeBSMidBottom,
                                                                    SWT.FULL_SELECTION | SWT.H_SCROLL
                                                                                    | SWT.V_SCROLL
                                                                                    | SWT.BORDER);
        permissionSetsTableViewer.setContentProvider(ArrayContentProvider.getInstance());

        Table permissionSetsTable = permissionSetsTableViewer.getTable();
        permissionSetsTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
        formToolkit.paintBordersFor(permissionSetsTable);
        permissionSetsTable.setHeaderVisible(true);
        permissionSetsTable.setLinesVisible(true);

        TableViewerColumn[] permissionSetsTableColumns = new TableViewerColumn[PERMISSIONSET_COLUMNNAMES.length];
        for (int j = 0; j < PERMISSIONSET_COLUMNNAMES.length; j++)
        {
            permissionSetsTableColumns[j] = new TableViewerColumn(permissionSetsTableViewer, SWT.NONE);
            permissionSetsTableColumns[j].getColumn().setWidth(100);
            permissionSetsTableColumns[j].getColumn().setText(PERMISSIONSET_COLUMNNAMES[j]);
        }

        permissionSetsTableViewer.setUseHashlookup(true);
        permissionSetsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
        permissionSetsTableViewer.setLabelProvider(new PermissionSetsLabelProvider());
        permissionSetsTableViewer.setInput(//blabla);

        // add the right composite and the second table

        //...
    }
@覆盖
受保护的void createFormContent(IManagedForm managedForm)
{
formToolkit=managedForm.getToolkit();
ScrolledForm=managedForm.getForm();
复合体=form.getBody();
GridLayout GridLayout=新的GridLayout(1,true);
gridLayout.horizontalSpacing=7;
body.setLayout(gridLayout);
formToolkit.Paintborders(车身);
//跳过
//业务服务左复合
compositeBSLeft=formToolkit.createComposite(compositeBSMain,SWT.NONE);
compositeBSLeft.setLayout(新的GridLayout(1,false));
compositeBSLeft.setLayoutData(新网格数据(SWT.FILL,SWT.CENTER,false,false,1,1));
formToolkit.Paintborders for(compositeBSLeft);
//业务服务中间组合
Section sctnBusinessServices=toolkit.createSection(正文,Section.TWISTIE | Section.TITLE_栏);
setLayoutData(新的GridData(SWT.FILL,SWT.CENTER,true,false,1,1));
工具包.画框(sctnBusinessServices);
sctnBusinessServices.setText(“业务服务”);
sctnBusinessServices.setExpanded(true);
//跳过
Composite-compositeBSMidBottom=formToolkit.createComposite(compositeBSMid,SWT.NONE);
setLayout(新的GridLayout(1,false));
setLayoutData(新的GridData(SWT.FILL,SWT.FILL,true,true,1,1));
formToolkit.Paintborders for(compositeBSMidBottom);
//权限集表
TableViewer PermissionSetTableViewer=新的TableViewer(compositeBSMidBottom,
SWT.FULL|U选择| SWT.H|U滚动
|SWT.V_卷轴
|边界);
permissionSetsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
Table permissionSetsTable=permissionSetsTableViewer.getTable();
setLayoutData(新的GridData(SWT.FILL,SWT.FILL,true,true,1,1));
formToolkit.PaintBorders(许可设置表);
PermissionSetTable.SetHeadService(true);
PermissionSetTable.setLinesVisible(真);
TableViewerColumn[]permissionSetsTableColumns=新的TableViewerColumn[PERMISSIONSET_COLUMNNAMES.length];
对于(int j=0;j
如果我省略了行
permissionSetTableColumns[j].getColumn().setWidth(100)然后我得到所需的结果,但所有列的宽度都为零

我有两个办法来解决这个问题

1:禁止
滚动窗体
水平滚动

2:在构建布局后,为列调用
setWidth()
pack()

两者都可能吗?我如何实现这一点

另一个问题是:如何解决左组合的固定宽度问题?因为如果我在初始化页面时在其中放入大量文本,则会破坏布局: