title: Scrollable Composite - auto resize - swt
body: <p>I have a Application Window using a Scrollable Composite.</p>
  
  <p>Inside scrollable composite we could have N composites (accordingly database data).</p>
  
  <p>How could I detected the size of children's composites to set the correct height?</p>
  
  <pre><code>/**
   * Create contents of the application window.
   * @param parent
   */
  @Override
  protected Control createContents(Composite parent) {
  
      final ScrolledComposite sc = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.BORDER);
      final Composite containerEditarAtendimento = new Composite(sc, SWT.BORDER);
      containerEditarAtendimento.setSize(800, 630);
      sc.setContent(containerEditarAtendimento);
      sc.setExpandHorizontal(true);
      sc.setExpandVertical(true);
      sc.setMinSize(containerEditarAtendimento.computeSize(820, 480));
      GridLayout gridLayout = new GridLayout(1, false);
      gridLayout.marginTop = 5;
      gridLayout.marginRight = 5;
      gridLayout.marginBottom = 5;
      gridLayout.marginLeft = 5;  
      containerEditarAtendimento.setLayout(gridLayout);
      { // Composite com as informações de atendimento.
          EditarAtendimentoComposite editarAtendimentoComposite = new EditarAtendimentoComposite(containerEditarAtendimento, SWT.BORDER);
          GridData gd_editarAtendimentoComposite = new GridData(GridData.FILL, GridData.FILL, true, false);
          gd_editarAtendimentoComposite.heightHint = 249;
          editarAtendimentoComposite.setLayoutData(gd_editarAtendimentoComposite);
      }
      {
          Composite compoExterno = formToolkit.createComposite(containerEditarAtendimento, SWT.BORDER);
          compoExterno.setLayout(new GridLayout(3, false));
          GridData gd_compoExterno = new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1);
          gd_compoExterno.heightHint = 153;
          compoExterno.setLayoutData(gd_compoExterno);
  
          formToolkit.paintBordersFor(compoExterno);
          {
              Label lblAnexos = formToolkit.createLabel(compoExterno, getLabel("label.anexos"), SWT.NONE);
          }
          new Label(compoExterno, SWT.NONE);
          {
              Button btnAddAnexo = formToolkit.createButton(compoExterno, getLabel("label.incluiranexo"), SWT.NONE);
              btnAddAnexo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
          }
          { // Composite com os anexos
              AnexosComposite anexosComposite = new AnexosComposite(compoExterno,SWT.BORDER);
              GridData gd_anexosComposite = new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1);
              gd_anexosComposite.heightHint = 107;
              anexosComposite.setLayoutData(gd_anexosComposite);
  
          }
  
      }
      {   // Composite onde ficará o expandable do diagnostico
          PlanoAcaoExternoComposite planoAcaoComposite = new PlanoAcaoExternoComposite(containerEditarAtendimento, SWT.BORDER);
          GridData gd_planoAcaoComposite = new GridData(GridData.FILL, GridData.FILL, true, false);
          planoAcaoComposite.setLayoutData(gd_planoAcaoComposite);
          formToolkit.adapt(planoAcaoComposite);
          formToolkit.paintBordersFor(planoAcaoComposite);
          planoAcaoComposite.layout(true, true);
          log.info("Height: {}",planoAcaoComposite.getClientArea().height);
          log.info("getSize().x: {}",planoAcaoComposite.getSize().x);
          log.info("getSize().y: {}",planoAcaoComposite.getSize().y);
          sc.setMinSize(containerEditarAtendimento.computeSize(800, 2000)); // HOW TO DYNAMICALLY SET HEIGHT?
      }
      sc.layout(true,true);
      return containerEditarAtendimento;
  }
  </code></pre>