如何将组组件左对齐

How to align group components to the left

我想使用分组框来改进我的 GUI。但是,当将组件添加到 Group 时,它们会移动到框的中心并且不再左对齐。如何让每个按钮和文本移动到左边距。

代码

GridLayout layout = new GridLayout(1, true);
layout.marginWidth = 300;
Group group = new Group(this, SWT.SHADOW_OUT);
group.setText("Open file locations");
group.setLayout(layout);

Button optionOne = new Button(group, SWT.CHECK | SWT.LEFT);
optionOne.setText(AppMessages.msg("Open file A") );

Button optionTwo = new Button(group, SWT.LEFT | SWT.CHECK);
optionTwo.setText(AppMessages.msg("Open file B") );

Need Space between two groups

你能尝试从布局中删除 marginWidth

按钮左对齐,但您已指定 300 像素的边距以在对齐完成之前转到按钮的左侧。

您为 GroupComposite 布局指定的边距值设置控件内的边距。