简体   繁体   English

两个按钮之间使用GridLayout的多余空间

[英]Extra spaces between two button using GridLayout

Could someone please explain me the reason of the gap between the two radio buttons ? 有人可以解释两个单选按钮之间的间距的原因吗? I even set the horizontal space to 0 but nothing has changed. 我什至将水平空间设置为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);
                }
 }

I would appreciate any explanation or solution. 我将不胜感激任何解释或解决方案。 向导的屏幕截图

Probably the Label with the text "Please enter the key size of your algorithm" is on the first column of the GridLayout , therefore all the rows are affected by its size. 带有文本"Please enter the key size of your algorithm"Label可能位于GridLayout的第一列上,因此所有行均受其大小影响。

You should divide the two sections, for example using different Composites with different layouts, one for the first Label and another for the content with the buttons. 您应该划分两个部分,例如使用具有不同布局的不同Composites ,一个用于第一个Label ,另一个用于使用按钮的内容。

For example: 例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM