我有一个SWT Shell,它有一些我无法摆脱的未知填充或边框。以下是我正在谈论的内容的截图。边界问题是绿色。我如何摆脱它,因为我的元素看起来会更好地直接压在shell的一侧?
提前致谢:D
public static void main(String[] args) {
Display display = new Display();
Shell rootShell = new Shell(display);
rootShell.setBackground(SWTGraphicUtil.getColorSafely(0, 255, 0));
GridLayout rootLayout = new GridLayout();
rootLayout.numColumns = 3;
rootLayout.horizontalSpacing = 0;
rootLayout.verticalSpacing = 0;
rootLayout.marginTop = rootLayout.marginRight = rootLayout.marginBottom = rootLayout.marginLeft = 0;
rootShell.setLayout(rootLayout);
Label lbl = new Label(rootShell, SWT.NONE);
lbl.setText("WHAT WHAT WHAT WHAT WHAT WHAT WHAT");
lbl.setBackground(SWTGraphicUtil.getColorSafely(255, 0, 0));
Label lbl2 = new Label(rootShell, SWT.NONE);
lbl2.setText("WHAT WHAT WHAT WHAT WHAT WHAT WHAT");
lbl2.setBackground(SWTGraphicUtil.getColorSafely(255, 0, 255));
Label lbl3 = new Label(rootShell, SWT.NONE);
lbl3.setText("WHAT WHAT WHAT WHAT WHAT WHAT WHAT");
lbl3.setBackground(SWTGraphicUtil.getColorSafely(0, 0, 255));
rootShell.pack();
rootShell.open();
while (!rootShell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
答案 0 :(得分:1)
只需为rootLayout
设置另外两个变量:
rootLayout.marginWidth = 0;
rootLayout.marginHeight = 0;
这应该删除“填充”(实际上是一个边距;))。