2013-07-01 52 views
0

我在一个视图3个的TreeViewer对象状的配置一栏,我想,如果我最大化/最小化视图/ Eclipse窗口的大小,以同样增加。这里是我的代码:SWT的TreeViewer调整问题

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(); 

然而,当某一树的内容都是超越现在的视空间和I最大化/最小化的观点,那棵树观景空间获得比别人更大。

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

回答

0

如果你读的GridLayout的文档,你会发现你的答案:

构造一个给定的列数这一类的和一个新的实例,无论是否在列应该被迫具有相同的宽度。如果numColumns的值小于1,则布局不会设置任何控件的大小和位置。

到您问题的解决方法是更换这个(因为你是在谈论列):

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

有:

composite.setLayout(new GridLayout(3, true)); 
+0

感谢信息 – user2538778

+0

@ user2538778 [如何受理回答工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)... – Baz