我试图在我的GUI的第二列(任务名称)中插入jface TreeViewer,但它与第一列(任务ID)合并。那么我怎样才能让控件将它从一列移到第二列。
答案 0 :(得分:1)
使用GridLayout
实现此目标的最简单方法是插入虚拟Label
,占用TreeViewer
前面的空格:
public static void main(String[] args)
{
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("StackOverflow");
shell.setLayout(new GridLayout(3, true));
/* Top row */
new Button(shell, SWT.PUSH).setText("Button");
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
/* Middle row */
new Label(shell, SWT.NONE);
new Button(shell, SWT.PUSH).setText("Button");
new Label(shell, SWT.NONE);
/* Bottom row */
new Label(shell, SWT.NONE);
new Label(shell, SWT.NONE);
new Button(shell, SWT.PUSH).setText("Button");
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
产生这个: