Adam Arold Adam Arold - 1 year ago 84
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.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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download