
[英]How to get rid of wasted space in SWT ScrolledComposite when the scrollbars are not shown
[英]ScrolledComposite showing no scrollbars when set to expand
我的问题是,如果我的滚动复合材料有
scrolledWrapper.setExpandHorizontal(true);
scrolledWrapper.setExpandVertical(true);
它在整个ViewPart上正确扩展,但如果我收缩View,则不会出现滚动条。
如果我没有设置展开,则滚动条会出现,但滚动的复合材料内的整个复合材料不会展开。
GridLayout gridLayout = new GridLayout(1, true);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false);
ScrolledComposite scrolledWrapper = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
scrolledWrapper.setLayout(gridLayout);
// if set the scrollbars dont appear but the composite expand on the whole view
scrolledWrapper.setExpandHorizontal(true);
scrolledWrapper.setExpandVertical(true);
scrolledWrapper.setLayoutData(gridData);
scrolledWrapper.setBackground(Display.getCurrent().getSystemColor(BG_COLOR));
有人知道如何设置Composite以扩展到我的整个视图,但是当视图缩小时还会显示滚动条吗?
我找到了一个解决方案:
您需要设置最小尺寸。 复合材料需要知道它的尺寸是小的
scrolledWrapper.setMinSize(wrapper.computeSize(SWT.DEFAULT, SWT.DEFAULT));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.