有人可以解释一下两个单选按钮之间差距的原因吗? 我甚至将水平空间设置为0但没有任何改变。
case composed:
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
new Label(container, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(new GridLayout(4, false));
for (int j = 0; j < this.itr; j++) {
Button[] radioButton = new Button[answers.size()];
for (int i = 0; i < answers.size(); i++) {
String ans = answers.get(i).getValue();
radioButton[i] = new Button(container, SWT.RADIO);
radioButton[i].setText(ans);
}
Text[] textField = new Text[answers.size()];
for (int i = 0; i < answers.size(); i++) {
textField[i] = new Text(container, SWT.SINGLE | SWT.BORDER);
for (int i = 0; i < answers.size(); i++) {
textField[i] = new Text(container, SWT.SINGLE | SWT.BORDER);
}
}
答案 0 :(得分:2)
Label
"Please enter the key size of your algorithm"
可能位于GridLayout
的第一列,因此所有行都会受到其大小的影响。
您应该将这两个部分分开,例如使用不同布局的不同Composites
,第一个用于第一个Label
,另一个用于带有按钮的内容。
例如:
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
container.setLayout(new GridLayout(1, false));
Composite questionContainer = new Composite(container, SWT.NONE);
questionContainer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
questionContainer.setLayout(new FillLayout());
Label question = new Label(questionContainer, SWT.NONE);
question.setText("Please enter the key size of your algorithm");
Composite contentContainer = new Composite(container, SWT.NONE);
contentContainer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
contentContainer.setLayout(new GridLayout(4, false));
// rest of the content using contentContainer as parent