第一
SWT.FILL
和
SWT.WRAP
是
不
的有效样式
Composite
. 控件的Javadoc指定可以使用哪些样式。
使用类似以下内容:
Composite composite = new Composite(parent, SWT.BORDER);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, false);
composite.setLayoutData(gridData);
composite.setLayout(new GridLayout(3, false));
Label label = new Label(composite, SWT.BEGINNING);
label.setText("Test");
label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Button but1 = new Button(composite, SWT.PUSH);
but1.setText("OK");
but1.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
Button but2 = new Button(composite, SWT.PUSH);
but2.setText("Close");
but2.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
标签的布局数据将在组合中获取额外的空间,并且按钮具有端点对齐。