简体   繁体   中英

SWT TreeViewer resize issue

I have 3 treeviewer objects in one view in a column like disposition and I want their size to increase equally if I maximize/minimize the view/eclipse window. Here is my code:

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

However, when the contents of a certain tree are surpass the current viewing space and I maximize/minimize the view, that tree viewing space gets bigger than the others.

Is there a way to prevent this resize behaviour due to content size? Many thanks, ND

If you read the documentation of GridLayout , you will find your answer:

Constructs a new instance of this class given the number of columns, and whether or not the columns should be forced to have the same width . If numColumns has a value less than 1, the layout will not set the size and position of any controls.

The solution to your problem is replacing this (since you are talking about columns):

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

with:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM