2013-07-05 11 views
8

ScrolledFormのscrollBarで問題が発生することがあります。this guy in EclipseZone Forumと同じ問題が発生します(これは2005年に尋ねられた質問ですが、未解決のようです)。ScrolledFormでスクロールバーを無効にする方法は?

//The scrollbar should only be displayed in the TreeViewer,not the whole form The scrollbar should only be displayed in the TreeViewer,not the whole form.

+1

したがって、スクロールしたフォームは使用しないでください。別のコンテナを使用してください。 – jarodeells

+1

@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) –

+1

@ janhinkの例で問題を解決できましたか?私は同じ問題であると思われるものを持っているが、その解決策を働かせることができないので、あなたはそれが働くために必要なものが不思議なものを見つけた。 – NealSr

答えて

3

私はこの問題accross数回来て、このようにそれを解決してきました。その後、

@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

また、グリッドレイアウトデータを更新し、コンポジットをレイアウトする本文のサイズ変更リスナーにも注意してください。

希望すると助かります!

+0

コードサンプルをありがとうございます。私は、私のSashFormの親コンポジットとしてnotScrolledCompositeを使用しようとしました。右のスクロールバーを削除する代わりに、内部コントロール全体が消えます。この修正プログラムを使用したときに何か特別な処理が必要でしたか? – NealSr

+0

notScrolledCompositeに適切なレイアウトを設定しましたか? – janhink

関連する問題