我在一个列中的一个视图中有3个树查看器对象,比如配置,如果我最大化/最小化视图/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
发布于 2013-07-03 14:55:20
如果您阅读了GridLayout的文档,您将找到您的答案:
构造这个类的一个新实例,给定列数,以及是否应该强制这些列具有相同宽度的。如果numColumns的值小于1时,布局将不会设置任何控件的大小和位置。
您的问题的解决方案是替换它(因为您是在讨论列):
composite.setLayout(new GridLayout(1, false));通过以下方式:
composite.setLayout(new GridLayout(3, true));https://stackoverflow.com/questions/17403962
复制相似问题