title: Nested SWT Composites with conflicting GridLayout
body: <p>I'm new to SWT and am trying to create a page with several nested <code>Composite</code>s. I'm running into problems with using a <code>GridLayout</code> nested within <code>Composite</code>s of other layout types.</p>
  
  <p>This is some simplified mock code that illustrates what it is I'm trying to accomplish, and the error I'm running into:</p>
  
  <pre><code>package layouts_test;
  
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.custom.StackLayout;
  import org.eclipse.swt.layout.GridData;
  import org.eclipse.swt.layout.GridLayout;
  import org.eclipse.swt.layout.RowLayout;
  import org.eclipse.swt.widgets.Display;
  import org.eclipse.swt.widgets.Shell;
  import org.eclipse.swt.widgets.Composite;
  
  public class LayoutsTest {
  
    public static void main(String[] args) {
  
      Display display = new Display();
      Shell shell = new Shell(display);
  
      // Composite that contains all nested Composites
      Composite pageComposite = new Composite(shell, SWT.NONE);
      final StackLayout stackLayout = new StackLayout();
      pageComposite.setLayout(stackLayout);
  
      // Construct some Composites to stack on the pageComposite
      Composite stackComposite1 = new Composite(pageComposite, SWT.NONE);
      stackComposite1.setLayout(new RowLayout(SWT.VERTICAL));
      Composite stackComposite2 = new Composite(pageComposite, SWT.NONE);
      stackComposite2.setLayout(new FillLayout());
  
      // Construct a grid composite to go into stackComposite1
      Composite gridComposite = new Composite(stackComposite1, SWT.NONE);
      gridComposite.setLayout(new GridLayout(3, true));
      gridComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      gridComposite.layout();
  
      // Arbitrarily set stackComposite1 on top
      stackLayout.topControl = stackComposite1;
      stackComposite1.layout();
  
      shell.pack();
      shell.open();
      while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
          display.sleep();
        }
      }
  
      display.dispose();
      return;
    }
  
  }
  </code></pre>
  
  <p>When I run this code, I get the following exception complaining that <code>stackComposite1</code> apparently is using <code>GridData</code> when it should be using <code>RowData</code> to lay out:</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCastException: org.eclipse.swt.layout.GridData cannot be cast to org.eclipse.swt.layout.RowData
  at org.eclipse.swt.layout.RowLayout.layoutVertical(RowLayout.java:367)
  at org.eclipse.swt.layout.RowLayout.layout(RowLayout.java:239)
  at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1291)
  at org.eclipse.swt.widgets.Composite.updateLayout(Composite.java:1277)
  at org.eclipse.swt.widgets.Composite.layout(Composite.java:666)
  at org.eclipse.swt.widgets.Composite.layout(Composite.java:624)
  at org.eclipse.swt.widgets.Composite.layout(Composite.java:587)
  at layouts_test.LayoutsTest.main(LayoutsTest.java:39)
  </code></pre>
  
  <p>If I change the layout type of <code>stackComposite1</code> to <code>FillLayout</code>, I receive a similar error, complaining about using <code>GridData</code> instead of <code>FillData</code>. However, when I remove the <code>gridComposite</code> altogether from the code, it works fine.</p>
  
  <p>I feel like I'm missing something very crucial here. As far as I understood, layouts only affect the way a <code>Composite</code> arranges UI elements contained within itself. Why is the nested <code>gridComposite</code> forcing its parent <code>stackComposite1</code> to also use <code>GridData</code> when I clearly am setting it up with another layout type altogether?</p>