0

我正在使用带有 fillLayout 作为内部复合材料和 ScrollComposite 作为外部复合材料的复合材料。

我已经固定了外部复合材料的大小。当我在外部复合中有滚动条但内部复合中没有滚动条时,当我将复合数据导出为 png 时,我将获得完整的信息。但是当显示的信息太大时就会出现问题,因为内部复合也有滚动条

这只是所做工作的一小部分:

FillLayout layout = new FillLayout(SWT.HORIZONTAL);

final ScrolledComposite scrolledComposite = new ScrolledComposite(getContainer(), SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
        scrolledComposite.setExpandHorizontal(true);
        scrolledComposite.setExpandVertical(true);

final Composite composite = new Composite(scrolledComposite, SWT.NONE);     
composite.setLayout(layout);

GraphViewer gvTree = new GraphViewer(composite, SWT.NONE);

<Code to populate data in the tree>

gvTree.setLayoutAlgorithm(treeLayout,true); 

scrolledComposite.setContent(composite);
scrolledComposite.setMinSize(1000,composite.getBounds().height);
4

1 回答 1

0

我发现,当外部复合为 ScrolledComposite 时,为了避免内部复合出现滚动条,我们需要确保 ScrolledComposite 的 minSize 始终大于内部复合大小。

为了确保 ScrolledComposite 大小正确,我更改了

 scrolledComposite.setMinSize(1000,composite.getBounds().height);
**to** 
scrolledComposite.setMinSize(gvTree.getNodeElements().length*160,
composite.getBounds().height);

这确保了在图创建之后 ScrolledComposite 总是大于等于内部组合的当前大小。

希望这可以帮助。

于 2014-11-11T10:38:38.317 回答