Java UI在Eclipse RCP和SWT中做了一些奇怪的事情
我已经绝望了,因为我无法在EclipseRCP中修复我的用户界面。所以我希望你能帮助我。这是屏幕,我想很明显是什么困扰着我: 下面是没有标签和文本的代码(我粘贴了第一个标签和文本,其余的都一样,setSize()只在每个部分的第一个标签上完成):Java UI在Eclipse RCP和SWT中做了一些奇怪的事情,java,eclipse,swt,rcp,Java,Eclipse,Swt,Rcp,我已经绝望了,因为我无法在EclipseRCP中修复我的用户界面。所以我希望你能帮助我。这是屏幕,我想很明显是什么困扰着我: 下面是没有标签和文本的代码(我粘贴了第一个标签和文本,其余的都一样,setSize()只在每个部分的第一个标签上完成): 提前谢谢 我看不出您的代码有任何明显的错误,但以下是我对如何继续的建议: 将外部布局更改为使用带两列的GridLayout。没有理由使用ColumnLayout 确保所有内容的命名一致(rightSection->rightDownSection)
提前谢谢 我看不出您的代码有任何明显的错误,但以下是我对如何继续的建议:
我认为如果你仔细地完成这些步骤,你会发现错误,这很可能是一个简单的错误。我经常发现问题只是在清理和简化代码。谢谢你的回答。我把布局改成了MigLayout,效果非常好。
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));