如何使用所有显示屏尺寸固定的SWT设计如下图?

How to design like below picture using SWT which is fixed in all display screen size?

我正在尝试使用 swt 设计如下图所示。我使用了 FormLayout,我需要给出宽度和高度,这对于所有屏幕尺寸都是固定的。但我想根据屏幕尺寸调整大小。我如何实施它?

您可以 GridLayout 使用足够的中间复合材料来做到这一点:

// Assumes 'parent' has FillLayout which will be the case for an e4 part

Composite outer = new Composite(parent, SWT.NONE);

outer.setLayout(new GridLayout());

Composite intermediate = new Composite(outer, SWT.NONE);
intermediate.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

intermediate.setLayout(new GridLayout());

Composite inner = new Composite(intermediate, SWT.NONE);
inner.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));

inner.setLayout(new GridLayout(4, false));

Label label1 = new Label(inner, SWT.LEAD);
label1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
label1.setText("TopLevelPath");

Text text1 = new Text(inner, SWT.SINGLE | SWT.BORDER);
text1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

Label endLabel = new Label(inner, SWT.PUSH);
endLabel.setText("but1");

endLabel = new Label(inner, SWT.PUSH);
endLabel.setText("but2");

Label label2 = new Label(inner, SWT.LEAD);
label2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
label2.setText("Alt TopLevelPath (optional)");

Text text2 = new Text(inner, SWT.SINGLE | SWT.BORDER);
text2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));