嗨我在SWT中遇到布局问题,我想用4个大小相同的列表创建一个应用程序。当列表为空时,每个列表看起来都很好,但是当我将使用覆盖整个组合的数据来完成其中一个列表时。
并列出数据:
我知道这是错误的布局,所以我会告诉你一些来源:
shlPirotechnikafcwnxrap.setLayout(new FillLayout(SWT.HORIZONTAL));
......
Composite mainComposite = new Composite(shlPirotechnikafcwnxrap,
SWT.NONE);
mainComposite.setLayout(new FormLayout());
......
Composite rightCenterComposite = new Composite(mainComposite, SWT.NONE);
rightCenterComposite.setLayoutData(new FormData());
rightCenterComposite.setLayout(new GridLayout());
rightCenterComposite.setLayoutData(GUIHelper.getFormData(5, 100, 30, 100));
TabFolder tabFolder = new TabFolder(rightCenterComposite, SWT.NONE);
tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
/**
* TAB ITEM
*/
TabItem tbtmSql = new TabItem(tabFolder, SWT.NONE);
tbtmSql.setText("SQL");
/**
* Composite inside TabItem
*/
Composite sqlTabComposite = new Composite(tabFolder, SWT.NONE);
GridLayout gl_sqlTabComposite = new GridLayout();
gl_sqlTabComposite.makeColumnsEqualWidth = true;
gl_sqlTabComposite.numColumns = 2;
sqlTabComposite.setLayout(gl_sqlTabComposite);
sqlTabComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
tbtmSql.setControl(sqlTabComposite);
Group grpSowaKluczoweSql = new Group(sqlTabComposite, SWT.NONE);
grpSowaKluczoweSql.setLayout(new FormLayout());
grpSowaKluczoweSql.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
grpSowaKluczoweSql.setText("S\u0142owa kluczowe i operatory SQL:");
List listSlowaKluczoweSql = new List(grpSowaKluczoweSql, SWT.BORDER | SWT.V_SCROLL);
listSlowaKluczoweSql.setLayoutData(new FormData());
listSlowaKluczoweSql.setLayoutData(GUIHelper.getFormData(0, 100, 0, 100));
Group grpTabele = new Group(sqlTabComposite, SWT.NONE);
grpTabele.setLayout(new FormLayout());
grpTabele.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
grpTabele.setText("Nazwy tabel:");
List listTabele = new List(grpTabele, SWT.BORDER | SWT.V_SCROLL);
listTabele.setLayoutData(new FormData());
listTabele.setLayoutData(GUIHelper.getFormData(0, 100, 0, 100));
答案 0 :(得分:1)
正因为如此:sqlTabComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
您正在使用FILL
+获取多余空间。尝试使用适当的布局常量,例如BEGINNING
用于水平对齐,TOP
用于垂直对齐。同时将grabExcessVerticalSpace
设置为false。检查所有相关的地方。