使用 GridLayout 两个按钮之间的额外空间
Extra spaces between two button using GridLayout
谁能解释一下为什么两个单选按钮之间有间隙?
我什至将水平 space 设置为 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);
}
}
如果有任何解释或解决方案,我将不胜感激。
可能带有文本 "Please enter the key size of your algorithm"
的 Label
位于 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
谁能解释一下为什么两个单选按钮之间有间隙? 我什至将水平 space 设置为 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);
}
}
如果有任何解释或解决方案,我将不胜感激。
可能带有文本 "Please enter the key size of your algorithm"
的 Label
位于 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