ScrolledForm
的滚动条有时会导致问题。我在 EclipseZone 论坛中遇到了同样的问题(这是 2005 年提出的问题,但似乎没有解决)。
//The scrollbar should only be displayed in the TreeViewer,not the whole form
ScrolledForm
的滚动条有时会导致问题。我在 EclipseZone 论坛中遇到了同样的问题(这是 2005 年提出的问题,但似乎没有解决)。
//The scrollbar should only be displayed in the TreeViewer,not the whole form
我已经多次遇到这个问题并像这样解决它:
@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);
}
});
}
注意GridLayout
表单正文中的 ,然后将宽度和高度设置hint
为复合的GridLayoutData
.
还要注意主体上的调整大小侦听器,它更新网格布局数据并布局复合。
希望能帮助到你!