我试图在 GUI 的第二列(任务名称)中插入 jface TreeViewer,但它与第一列(任务 ID)合并。那么我怎样才能获得将其从一列转移到第二列的控件。
最佳答案
使用 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();
}
产生这个:
关于java - 如何在第二列或特定列中插入 jface TreeViewer?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19290650/