title: SWT Shell resize depending on children
body: <p>I'm working on this <code>Composite</code> canvas on which other <code>Composite</code>s may be added and removed.</p>
  
  <p>My understanding of how the whole laying-out concept is still in the fog.</p>
  
  <p><b>When children are added to the container, given the fact that the container has a <code>GridData</code> which fills in the parent, shouldn't the parent also know that the child resized? Children remain hidden after their container has been laid out, because of the shell (top parent).</b></p>
  
  <p>If the question is too vague, do not hesitate to ask for more details. Also, try your best not pointing me to the <em>Understanding layouts in SWT</em> article.</p>
  
  <pre><code>/**
   * 
   * @author ggrec
   *
   */
  public class SSCCE
  {
  
      // ==================== 2. Instance Fields ============================
  
      private Composite componentContainer;
  
      private int componentCount = 0;
  
      // ==================== 3. Static Methods =============================
  
      public static void main(final String[] args)
      {
          new SSCCE();
      }
  
      // ==================== 4. Constructors ===============================
  
      private SSCCE()
      {
          final Display display = new Display();
          final Shell shell = new Shell(display);
          shell.setLayout(new GridLayout(1, false));
  
          createContents(shell);
  
          shell.pack();
          shell.open();
          while (!shell.isDisposed())
          {
              if (!display.readAndDispatch())
                  display.sleep();
          }
          display.dispose();
      }
  
      // ==================== 5. Creators ===================================
  
      private void createContents(final Composite parent)
      {
          parent.setLayout(new GridLayout());
          parent.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
  
          final Button button = new Button(parent, SWT.PUSH);
          button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
          button.setText("Add New Component");
  
          button.addSelectionListener(new SelectionAdapter()
          {
              @Override public void widgetSelected(final SelectionEvent e)
              {
                  addNewComponent();
  
                  componentContainer.layout();
              }
          });
  
          componentContainer = new Composite(parent, SWT.BORDER);
          componentContainer.setLayout(new GridLayout());
          componentContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      }
  
      // ==================== 6. Action Methods =============================
  
      private void addNewComponent()
      {
          final Composite component = new Composite(componentContainer, SWT.BORDER);
          component.setLayout(new FillLayout());
          component.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
  
          final Label label = new Label(component, SWT.NONE);
          label.setText( String.valueOf(componentCount++) );
      }
  }
  </code></pre>
  
  <p><b>Fun fact</b>:
  This question is veeeery related <a href="https://stackoverflow.com/questions/20204367/how-to-dynamically-add-swt-widgets-to-a-composite">to this other one, that was posted 9 minutes ago</a>. Someone is either psychic or stalking me.</p>