簡體   English   中英

兩個按鈕之間使用GridLayout的多余空間

[英]Extra spaces between two button using GridLayout

有人可以解釋兩個單選按鈕之間的間距的原因嗎? 我什至將水平空間設置為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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM