ScrolledForm
的滚动条有时会导致问题。我遇到了与this guy in EclipseZone Forum相同的问题(这是2005年提出的一个问题,但似乎尚未解决)。如何禁用ScrolledForm中的滚动条?
//The scrollbar should only be displayed in the TreeViewer,not the whole form
ScrolledForm
的滚动条有时会导致问题。我遇到了与this guy in EclipseZone Forum相同的问题(这是2005年提出的一个问题,但似乎尚未解决)。如何禁用ScrolledForm中的滚动条?
//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
。
另请注意,在更新网格布局数据和布局复合体的正文上调整大小侦听器。
希望它有帮助!
所以不要使用滚动窗体。使用不同的容器。 – jarodeells
@jarodeells这是因为ManagedForm的方法'getForm()'返回一个ScrolledForm。(http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi% 2Forg%2Feclipse%2Fui%2Fforms%2FManagedForm.html) –
你能用@ janhink的例子解决你的问题吗?我有似乎是同样的问题,但无法得到该解决方案的工作,所以你找到一个我很好奇它是如何工作的。 – NealSr