<p>What did I do wrong?</p>

<p>Here is an excerpt from my code:</p>

<pre><code>public void createPartControl(Composite parent) {
  parent.setLayout(new FillLayout());
  ScrolledComposite scrollBox = new ScrolledComposite(parent, SWT.V_SCROLL);
  scrollBox.setExpandHorizontal(true);
  mParent = new Composite(scrollBox, SWT.NONE);
  scrollBox.setContent(mParent);
  FormLayout layout = new FormLayout();
  mParent.setLayout(layout);
  // Adds a bunch of controls here
  mParent.layout();
  mParent.setSize(mParent.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
}
</code></pre>

<p>...but it clips the last button:
<img src="https://i.stack.imgur.com/1ubzc.png" alt="alt text" title="Screenshot"></p>

<p>bigbrother82: That didn't work.</p>

<p>SCdF: I tried your suggestion, and now the scrollbars are gone.  I need to work some more on that.</p>

[{'answer_id': 35503, 'author': 'SCdF', 'author_id': 1666, 'author_profile': 'https://Stackoverflow.com/users/1666', 'pm_score': 0, 'selected': False, 'text': "<p>Don't you need to recompute the size of the scrollBox after the layout?</p>\n"}, {'answer_id': 36306, 'author': 'Jacob Schoen', 'author_id': 3340, 'author_profile': 'https://Stackoverflow.com/users/3340', 'pm_score': 2, 'selected': False, 'text': '<p>If I am not mistaken you need to swap the </p>\n\n<pre><code>mParent.layout();\n</code></pre>\n\n<p>and</p>\n\n<pre><code>mParent.setSize(mParent.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));\n</code></pre>\n\n<p>so that you have:</p>\n\n<pre><code>public void createPartControl(Composite parent) {\n  parent.setLayout(new FillLayout());\n  ScrolledComposite scrollBox = new ScrolledComposite(parent, SWT.V_SCROLL);\n  scrollBox.setExpandHorizontal(true);\n  mParent = new Composite(scrollBox, SWT.NONE);\n  scrollBox.setContent(mParent);\n  FormLayout layout = new FormLayout();\n  mParent.setLayout(layout);\n  // Adds a bunch of controls here\n  mParent.setSize(mParent.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));\n  mParent.layout();\n}\n</code></pre>\n'}, {'answer_id': 152324, 'author': 'alexmcchessers', 'author_id': 998, 'author_profile': 'https://Stackoverflow.com/users/998', 'pm_score': 0, 'selected': False, 'text': '<p>Try setting .setMinWidth and .setMinHeight on the ScrolledComposite once the layout has been done, passing it the size of the main composite.</p>\n'}, {'answer_id': 159454, 'author': 'qualidafial', 'author_id': 13253, 'author_profile': 'https://Stackoverflow.com/users/13253', 'pm_score': 5, 'selected': True, 'text': '<p>This is a common hurdle when using <code>ScrolledComposite</code>.  When it gets so small that the scroll bar must be shown, the client control has to shrink horizontally to make room for the scroll bar.  This has the side effect of making some labels wrap lines, which moved the following controls farther down, which increased the minimum height needed by the content composite.</p>\n\n<p>You need to listen for width changes on the content composite (<code>mParent</code>), compute the minimum height again given the new content width, and call <code>setMinHeight()</code> on the scrolled composite with new height.</p>\n\n<pre><code>public void createPartControl(Composite parent) {\n  parent.setLayout(new FillLayout());\n  ScrolledComposite scrollBox = new ScrolledComposite(parent, SWT.V_SCROLL);\n  scrollBox.setExpandHorizontal(true);\n  scrollBox.setExpandVertical(true);\n\n  // Using 0 here ensures the horizontal scroll bar will never appear.  If\n  // you want the horizontal bar to appear at some threshold (say 100\n  // pixels) then send that value instead.\n  scrollBox.setMinWidth(0);\n\n  mParent = new Composite(scrollBox, SWT.NONE);\n\n  FormLayout layout = new FormLayout();\n  mParent.setLayout(layout);\n\n  // Adds a bunch of controls here\n\n  mParent.addListener(SWT.Resize, new Listener() {\n    int width = -1;\n    public void handleEvent(Event e) {\n      int newWidth = mParent.getSize().x;\n      if (newWidth != width) {\n        scrollBox.setMinHeight(mParent.computeSize(newWidth, SWT.DEFAULT).y);\n        width = newWidth;\n      }\n    }\n  }\n\n  // Wait until here to set content pane.  This way the resize listener will\n  // fire when the scrolled composite first resizes mParent, which in turn\n  // computes the minimum height and calls setMinHeight()\n  scrollBox.setContent(mParent);\n}\n</code></pre>\n\n<p>In listening for size changes, note that we ignore any resize events where the width stays the same.  This is because changes in the height of the content do not affect the <i>minimum</i> height of the content, as long as the width is the same.</p>\n'}]
['https://Stackoverflow.com/questions/35123', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3657/']