ScrolledComposite showing two scrollbars each for vertical & horizontal scroll

165 Views Asked by At

My current application is a RCP application using eclipse framework. There is a view whose composite is given to a Scrolled Composite and then all the relevant composites are made with the ScrolledComposite as the parent.

protected void createContent(Composite parent) 
{
 ScrolledComposite form = new ScrolledForm(parent,SWT.H_SCROLL|SWT.V_SCROLL);
 GridLayout layout = new GridLayout(1, false);
 form.getBody().setLayout(layout);
 ......................
 .........................
}

The issue is that at times there are two vertical and two horizontal scrollbars visible. One is of the main view and the second is for the ScrolledComposite.

I have implemented a ResizeListener that will change the MinSize of the SCrolledLayout dynamically.

Rectangle rect = form.getClientArea();
form.setMinSize(SWT.DEFAULT,SWT.DEFAULT);

However Still at times there are two Scrollbars visible but they are of no use and they look annoying. So Since the scrollbars are of no use I am disabling them in the ResizeListener itself.

Rectangle rect = form.getClientArea();
form.getHorizontalBar().setVisible(false);
form.getVerticalBar().setVisible(false);
form.setMinSize(SWT.DEFAULT,SWT.DEFAULT);

Is there a better way to do this or am I goofing up somewhere.

0

There are 0 best solutions below