0

我已经绝望了,因为我无法在 Eclipse RCP 中修复我的用户界面。所以我希望你能帮助我。这是屏幕,我想很明显是什么在困扰我:http: //imgur.com/QOf0O

这是没有标签和文本的代码(我发布了第一个标签和文本,其余部分相同,setSize() 仅在每个部分的第一个标签上完成):

Composite c = this.toolkit.createComposite(parent);
    c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    ColumnLayout columnLayout = new ColumnLayout();
    columnLayout.minNumColumns = 2;
    columnLayout.maxNumColumns = 2;
    c.setLayout(columnLayout);

Section leftUpSection = this.toolkit.createSection(c,
            Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE
                    | Section.EXPANDED);
    leftUpSection.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            KundeEditor.this.form.reflow(true);
        }
    });
    leftUpSection.setText("Daten");
    leftUpSection
            .setLayoutData(new ColumnLayoutData(ColumnLayoutData.FILL));
    Composite leftUp = this.toolkit.createComposite(leftUpSection);
    leftUp.setLayout(new GridLayout(2, false));
            lblNachname.setSize(230, lblNachname.getSize().y);
        this.txtNachname = this.toolkit.createText(leftUp,
                this.kunde.getNachname(), SWT.LEFT | SWT.BORDER);
        this.txtNachname.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        this.txtNachname.addModifyListener(listener);

Section leftDownSection = this.toolkit.createSection(c,
            Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE
                    | Section.EXPANDED);
    leftDownSection.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            KundeEditor.this.form.reflow(true);
        }
    });
    leftDownSection.setText("Kontoinformation");
    leftDownSection.setLayoutData(new ColumnLayoutData(
            ColumnLayoutData.FILL));
    Composite leftDown = this.toolkit.createComposite(leftDownSection);
    leftDown.setLayout(new GridLayout(2, false));

Section rightSection = this.toolkit.createSection(c,
            Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE
                    | Section.EXPANDED);
    rightSection.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            KundeEditor.this.form.reflow(true);
        }
    });
    rightSection.setText("Kontaktinformation");
    rightSection.setLayoutData(new ColumnLayoutData(ColumnLayoutData.FILL));
    Composite right = this.toolkit.createComposite(rightSection);
    right.setLayout(new GridLayout(2, false));

Section rightDownSection = this.toolkit.createSection(c,
            Section.DESCRIPTION | Section.TITLE_BAR | Section.TWISTIE
                    | Section.EXPANDED);
    rightDownSection.addExpansionListener(new ExpansionAdapter() {
        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            KundeEditor.this.form.reflow(true);
        }
    });

    rightDownSection.setText("Mitgliedsinformation");
            rightDownSection.setLayoutData(new ColumnLayoutData(
            ColumnLayoutData.FILL));
    Composite rightDown = this.toolkit.createComposite(rightDownSection);
    rightDown.setLayout(new GridLayout(2, false));

提前致谢!

4

1 回答 1

0

我看不出您的代码有任何明显错误,但这是我对如何进行的建议:

  1. 更改您的外部布局以使用具有两列的 GridLayout。没有理由使用 ColumnLayout。
  2. 确保所有内容的命名一致(rightSection -> rightDownSection)。
  3. 确保所有内容的格式一致

我认为,如果您仔细执行这些步骤,您会发现错误,这可能是一个简单的错误。我经常发现问题只是清理和简化代码。

于 2012-05-07T03:23:58.230 回答