【发布时间】:2017-10-16 13:00:41
【问题描述】:
我正在做一个 Eclipse 插件,它是一个多页表单编辑器。 在一个页面上,我希望一些数据以表格和树的形式呈现。 我想将页面垂直分成两半。 为了实现这一点,我想使用组(左组,右组)。
public class UtilityPage extends FormPage {
public UtilityPage(FormEditor editor, String id, String title) {
super(editor, id, title);
// TODO Auto-generated constructor stub
}
@Override
protected void createFormContent(IManagedForm managedForm) {
ScrolledForm scrolledForm = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
Composite body = scrolledForm.getBody();
GridLayout layout = new GridLayout();
body.setLayout(layout);
layout.makeColumnsEqualWidth = true;
layout.numColumns = 2;
Group leftGroup = new Group(body, SWT.SHADOW_IN);
Group rightGroup = new Group(body, SWT.SHADOW_IN);
leftGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
rightGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
Label testLabel = new Label(rightGroup, SWT.CENTER);
testLabel.setText("<Test>");
Label testLabel2 = new Label(leftGroup, SWT.CENTER);
testLabel2.setText("<Test>");
leftGroup.pack();
rightGroup.pack();
}
}
我的问题是这会导致两个没有任何内容的空组。
https://i.imgur.com/5B7sXqS.png
这在我之前发生过多次,但我一直在解决它。
但是由于我不知道如何完成我想要的布局,我在这里问你们是否有其他想法。或者如果你知道我做错了什么。
【问题讨论】: