Tôi đã đi qua vấn đề này nhiều lần và giải quyết nó như thế này:
@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);
}
});
}
Thông báo các GridLayout
trong cơ thể của hình thức và sau đó thiết lập chiều rộng và chiều cao hint
đến tổng hợp của GridLayoutData
.
Cũng lưu ý trình lắng nghe thay đổi kích thước trên cơ thể cập nhật dữ liệu bố cục lưới và bố cục hỗn hợp.
Hy vọng điều đó sẽ hữu ích!
Vì vậy, không sử dụng biểu mẫu cuộn. Sử dụng một container khác. – jarodeells
@jarodeells đó là do phương thức 'getForm()' của ManagedForm trả về một ScrolledForm. (Http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi% 2Forg% 2Feclipse% 2Fui% 2Fforms% 2FManagedForm.html) –
bạn có thể giải quyết vấn đề của mình bằng ví dụ @ janhink không? Tôi có những gì dường như là cùng một vấn đề nhưng tôi không thể có được giải pháp đó để làm việc, vì vậy nó bạn tìm thấy một trong đó là tôi tò mò những gì nó đã làm cho nó làm việc. – NealSr