ScrolledForm
's scrollBar can sometimes cause problems.I meet the same problem with this guy in EclipseZone Forum (it's a question asked in 2005 but seems to be unresolved).
//The scrollbar should only be displayed in the TreeViewer,not the whole form
I've come accross this issue several times and solved it like this:
@Override
protected void createFormContent(IManagedForm managedForm) {
// set the form's body's layout to GridLayout
final Composite body = managedForm.getForm().getBody();
body.setLayout(new GridLayout());
// create the composite which should not have the scrollbar and set its layout data
// to GridData with width and height hints equal to the size of the form's body
final Composite notScrolledComposite = managedForm.getToolkit().createComposite(body);
final GridData gdata = GridDataFactory.fillDefaults()
.grab(true, true)
.hint(body.getClientArea().width, body.getClientArea().height)
.create();
notScrolledComposite.setLayoutData(gdata);
// add resize listener so the composite's width and height hints are updates when
// the form's body resizes
body.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
super.controlResized(e);
gdata.widthHint = body.getClientArea().width;
gdata.heightHint = body.getClientArea().height;
notScrolledComposite.layout(true);
}
});
}
Notice the GridLayout
in the form's body and then setting the width and height hint
to the composite's GridLayoutData
.
Also notice the resize listener on the body which updates the grid layout data and layouts the composite.
Hope it helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With