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

时间:2023-01-20 17:55:00

I am already desperated, because I can't fix my User Interface in Eclipse RCP. So I hope you can help me. Here is the screen and I guess it's obvious what is bugging me: http://imgur.com/QOf0O

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

Here is the code without the labels and the texts (I postet the first label and text, the rest is the same, setSize() is only done on the first label per section):

这是没有标签和文本的代码(我发布第一个标签和文本,其余部分相同,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));

Thanks in advance!

提前致谢!

1 个解决方案

#1


0  

I can't see anything obviously wrong with your code, but here is what I suggest for how to proceed:

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

  1. Change your outer layout to use GridLayout with two columns. There is no reason to use ColumnLayout.
  2. 更改外部布局以使用GridLayout和两列。没有理由使用ColumnLayout。

  3. Make sure everything is named consistently (rightSection -> rightDownSection).
  4. 确保一致命名(rightSection - > rightDownSection)。

  5. Make sure everything is formatted consistently
  6. 确保所有内容都格式一致

I think if you carefully go through these steps you will find the error which will likely be a simple mistake. Often I have found problems just be cleaning up and simplifying code.

我想如果你仔细检查这些步骤,你会发现错误,这可能是一个简单的错误。我常常发现问题只是清理和简化代码。

#1


0  

I can't see anything obviously wrong with your code, but here is what I suggest for how to proceed:

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

  1. Change your outer layout to use GridLayout with two columns. There is no reason to use ColumnLayout.
  2. 更改外部布局以使用GridLayout和两列。没有理由使用ColumnLayout。

  3. Make sure everything is named consistently (rightSection -> rightDownSection).
  4. 确保一致命名(rightSection - > rightDownSection)。

  5. Make sure everything is formatted consistently
  6. 确保所有内容都格式一致

I think if you carefully go through these steps you will find the error which will likely be a simple mistake. Often I have found problems just be cleaning up and simplifying code.

我想如果你仔细检查这些步骤,你会发现错误,这可能是一个简单的错误。我常常发现问题只是清理和简化代码。