0

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.

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. Screenshot of the wizard

Ben193
  • 45
  • 1
  • 12
  • Maybe the "fixed size" string contains white spaces to the right? You could try to remove them with `trim()`. – Loris Securo Oct 14 '17 at 17:53
  • I don't think so. All strings are pulled out from a json file and they have the same size. – Ben193 Oct 14 '17 at 17:56
  • Why there are 3 `new Label(container, SWT.NONE);` at the top? Are they used just as separators? But they should be 4 not 3, right? Maybe the first 1 has a different size... – Loris Securo Oct 14 '17 at 18:03
  • Since the question is a label and I have 4 widget to show, then I had to add 3 empty labels as separators, to keep the 4 on the same row – Ben193 Oct 14 '17 at 18:08

1 Answers1

2

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.

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.

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
Loris Securo
  • 7,538
  • 2
  • 17
  • 28