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