4

my problem is that if my Scrolled Composite has

scrolledWrapper.setExpandHorizontal(true);
scrolledWrapper.setExpandVertical(true);

it expands correctly on the whole ViewPart but if I shrink the View no scrollbars appear.

If I don't set the expand the scrollbars appear but the whole composite inside the scrolled composite dont expand.

    GridLayout gridLayout = new GridLayout(1, true);
    GridData gridData = new GridData(SWT.FILL, SWT.FILL, false, false);

    ScrolledComposite scrolledWrapper = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledWrapper.setLayout(gridLayout);
            // if set the scrollbars dont appear but the composite expand on the whole view
    scrolledWrapper.setExpandHorizontal(true);
    scrolledWrapper.setExpandVertical(true); 

    scrolledWrapper.setLayoutData(gridData);
    scrolledWrapper.setBackground(Display.getCurrent().getSystemColor(BG_COLOR));

Does someone know how I can set the Composite to expand onto my whole view but also show the scrollbars when the view is to shrinked?

Michael Brenndoerfer
  • 3,483
  • 2
  • 39
  • 50
  • possible duplicate of [Scrollable Composite - auto resize - swt](http://stackoverflow.com/questions/14445580/scrollable-composite-auto-resize-swt) – Baz Nov 07 '13 at 09:10
  • Or this: [How to fill a ScrolledComposite?](http://stackoverflow.com/questions/17827535/how-to-fill-a-scrolledcomposite) – Baz Nov 07 '13 at 09:15

1 Answers1

4

I've found a solution:

You need to set a min size. The composite needs to know at which size it's to small

scrolledWrapper.setMinSize(wrapper.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Michael Brenndoerfer
  • 3,483
  • 2
  • 39
  • 50