UI在带有SWT的Eclipse RCP中做了很奇怪的事情

时间:2012-05-05 21:35:13

标签: java eclipse swt rcp

我已经绝望了,因为我无法在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));

提前致谢!

1 个答案:

答案 0 :(得分:0)

我的代码看不出任何明显错误,但我建议如何继续:

  1. 更改外部布局以使用带有两列的GridLayout。没有理由使用ColumnLayout。
  2. 确保所有内容都一致命名(rightSection - > rightDownSection)。
  3. 确保所有内容的格式一致
  4. 我认为如果您仔细执行这些步骤,您会发现错误,这可能是一个简单的错误。我经常发现问题只是清理和简化代码。