0

我在一个视图中的一个视图中有 3 个 treeviewer 对象,如处置,如果我最大化/最小化视图/eclipse 窗口,我希望它们的大小同样增加。这是我的代码:

Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));

treeViewer1 = new TreeViewer(composite, SWT.BORDER);
tree1 = treeViewer1.getTree();
tree1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tree1.pack();

treeViewer2 = new TreeViewer(composite, SWT.BORDER);
tree2 = treeViewer2.getTree();
tree2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
tree2.pack();

treeViewer3 = new TreeViewer(composite, SWT.BORDER);
tree3 = treeViewer3.getTree();
tree3.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));            
tree3.pack();

然而,当某棵树的内容超过当前的查看空间并且我最大化/最小化视图时,该树的查看空间变得比其他的更大。

有没有办法防止由于内容大小而导致的这种调整大小行为?非常感谢,ND

4

1 回答 1

0

如果您阅读 的文档GridLayout,您会找到答案:

在给定列数以及是否应强制列具有相同宽度的情况下构造此类的新实例。如果 numColumns 的值小于 1,则布局不会设置任何控件的大小和位置。

您的问题的解决方案是替换它(因为您正在谈论列):

composite.setLayout(new GridLayout(1, false));

和:

composite.setLayout(new GridLayout(3, true));
于 2013-07-03T14:55:20.813 回答