我想在一个包含 2 个单选按钮的复合和组中创建一个标签。但是我在对齐它时遇到了问题。它没有与标签正确对齐。该组有一个我没有使用的文本或标题。由于该文本,它没有正确对齐。但是对于复合材料,我得到了正确的行为,并且它与标签正确对齐。那么有什么方法可以使用 group.copy 来复制相同的东西。下面包含我使用的快照和代码。
代码:
shell.setLayout(new GridLayout(2,false));
GridData grid=new GridData();
Composite comp=new Composite(shell, SWT.None);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
Label label = new Label(comp, SWT.None);
label.setText("Invertframe:");
org.eclipse.swt.widgets.Group group=new org.eclipse.swt.widgets.Group(shell, SWT.None);
GridLayout layout = new GridLayout(2, true);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 10;
layout.marginBottom = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
group.setLayout(layout);
group.setLayoutData(grid);
Button button =new Button(group, SWT.RADIO);
button.setText("ON");
Button button2 =new Button(group, SWT.RADIO);
button2.setText("OFF");
comp=new Composite(shell, SWT.None);
comp.setLayout(new GridLayout());
comp.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
label = new Label(comp, SWT.None);
label.setText("Invertframe:");
Composite composite2=new Composite(shell, SWT.BORDER);
layout = new GridLayout(2, true);
composite2.setLayout(layout);
layout.horizontalSpacing = 0;
layout.verticalSpacing = 10;
layout.marginBottom = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
button =new Button(composite2, SWT.RADIO);
button.setText("ON");
button2 =new Button(composite2, SWT.RADIO);
button2.setText("OFF");