1
我試圖在2列的GridLayout中顯示標籤。我似乎無法使其顯示文本和下面的水平線:水平線顯示不正確的SWT標籤
public void foo(){
popupShell = new Shell(Display.getDefault(), SWT.NO_TRIM | SWT.ON_TOP | SWT.MODELESS);
//popupShell.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
popupShell.setLayout(createNoMarginLayout(2, false));
Label history = new Label(popupShell, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL);
history.setText("History");
history.setVisible(true);
Label fill = new Label(popupShell, SWT.NONE);
fill.setSize(0,30);
}
public static GridLayout createNoMarginLayout(int numColumns, boolean makeColumnsEqualWidth) {
GridLayout layout = new GridLayout(numColumns, makeColumnsEqualWidth);
layout.verticalSpacing = 0;
layout.horizontalSpacing = 0;
layout.marginTop = 0;
layout.marginBottom = 0;
layout.marginLeft = 0;
layout.marginRight = 0;
layout.marginWidth = 0;
layout.marginHeight = 0;
return layout;
}
我得到的只是沒有文字的行。
我在做什麼錯?
謝謝格雷格, 我設置SWT.NONE初始標籤和我addded兩個額外的標籤,用SWT.HORIZONTAL。現在起作用了。 –