Java 如何将按钮放置在Eclipse主详细信息块中另一个按钮的下方?

Java 如何将按钮放置在Eclipse主详细信息块中另一个按钮的下方?,java,eclipse,eclipse-plugin,eclipse-rcp,Java,Eclipse,Eclipse Plugin,Eclipse Rcp,我目前有以下几点。问题是我想把按钮2直接放在按钮1的下面 我已经修改了这个代码 这是我的密码: protected void createMasterPart(final IManagedForm managedForm, Composite parent) { FormToolkit toolkit = managedForm.getToolkit(); Section section = toolkit.createSection(parent, Sectio

我目前有以下几点。问题是我想把
按钮2
直接放在
按钮1
的下面

我已经修改了这个代码

这是我的密码:

protected void createMasterPart(final IManagedForm managedForm,
        Composite parent) {
    FormToolkit toolkit = managedForm.getToolkit();
    Section section = toolkit.createSection(parent, Section.DESCRIPTION|Section.TITLE_BAR);
    section.setText("Test"); //$NON-NLS-1$
    section.setDescription("Test"); //$NON-NLS-1$
    section.marginWidth = 10;
    section.marginHeight = 5;
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    client.setLayout(layout);
    Table t = toolkit.createTable(client, SWT.NULL);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 20;
    gd.widthHint = 100;
    t.setLayoutData(gd);
    toolkit.paintBordersFor(client);
    Button button1 = toolkit.createButton(client, "Button 1", SWT.PUSH); //$NON-NLS-1$
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    button1.setLayoutData(gd);
    Button button2 = toolkit.createButton(client, "Button 2", SWT.PUSH); //$NON-NLS-1$
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    button2.setLayoutData(gd);
    section.setClient(client);
    final SectionPart spart = new SectionPart(section);
    managedForm.addPart(spart);
    TableViewer viewer = new TableViewer(t);
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            managedForm.fireSelectionChanged(spart, event.getSelection());
        }
    });
    viewer.setContentProvider(new MasterContentProvider());
    viewer.setLabelProvider(new MasterLabelProvider());
    viewer.setInput(page.getEditor().getEditorInput());
}

如何做到这一点?

由于您有两列,因此布局当前将表格放在左列的第一行,然后将第一个按钮放在右列。第二个按钮位于新行的左列

要使按钮进入右栏,您需要创建一个附加的
组合
,以容纳两个(或更多)按钮:


使用is
客户端
client
使用的是什么布局?您需要显示更多内容,显示整个方法。@greg-449对不起。我现在已经添加了完整的方法。
Composite buttComposite = toolkit.createComposite(client, SWT.NONE);
buttComposite.setLayout(new GridLayout());
buttComposite.setLayoutData(new GridData(SWT.BEGINNING, SWT.TOP, false, false));

Button button1 = toolkit.createButton(buttComposite, "Button 1", SWT.PUSH); 
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
button1.setLayoutData(gd);
Button button2 = toolkit.createButton(buttComposite, "Button 2", SWT.PUSH); 
gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
button2.setLayoutData(gd);