Adam Arold Adam Arold - 8 days ago 7
Java Question

How do I make a view scrollable in an Eclipse RCP application?

What I tried so far:

In createPartControl:

ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
sc.setLayoutData(new GridData(GridData.FILL_BOTH));
sc.setExpandVertical(true);
sc.setExpandHorizontal(true);
sc.setSize(ApplicationWorkbenchWindowAdvisor.WIDTH, ApplicationWorkbenchWindowAdvisor.HEIGHT);
final TabFolder tabFolder = new TabFolder(sc, SWT.TOP);


but this does not work. My problem is that if I resize my program window the scrollbars does not appear in my view. Any ideas?

Answer

The Javadoc of ScrolledComposite describes the two ways to use it, including example code. To sum them up:

  1. You either set the size of the control/composite contained in your ScrolledComposite on the control/composite itself
  2. Or you tell your ScrolledComposite the minimum size to use for its content.

Currently, you're doing neither. You're setting the size on the ScrolledComposite, but unless you don't use a layout manager, that doesn't make much sense. In any case, see the above link for some official example code.