如何使用 a (见此处Button
)将 a (垂直)定位在中心?使用:FormLayout
final Button button = new Button(shell, SWT.NONE);
button.setText("Button");
final FormData layoutData = new FormData();
layoutData.top = new FormAttachment(50);
layoutData.left = new FormAttachment(0);
layoutData.right = new FormAttachment(100);
button.setLayoutData(layoutData);
我最终得到
这并不奇怪,因为我告诉它把按钮的顶部放在中间(layoutData.top = new FormAttachment(50);
)。我怎样才能将按钮的中心放在中心?