title: Avoid setting parent in widget constructor in SWT?
body: <p>While <code>Swing</code> architecture supposes that widgets are "added" one into another, <code>SWT</code> uses another paradigm: each widget is created having parent set in the constructor.</p>
  
  <p>I think former approach is better, because I can isolate a code of creating each control.</p>
  
  <p>For example</p>
  
  <pre><code>// creating button 1
  JButton button1 = new JButton("Button 1");
  
  // creating button 2
  JButton button2 = new JButton("Button 2");
  
  // creating button 3
  JButton button3 = new JButton("Button 3");
  
  // creating panel
  JPanel panel = new JPanel();
  panel.setLayout(new FlowLayout());
  panel.add(button1);
  panel.add(button2);
  panel.add(button3);
  
  // creating frame
  JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(panel);
  
  
  frame.pack();
  frame.setVisible(true);
  </code></pre>
  
  <p>We can have three widgets here and each one is created in it's own block of code.</p>
  
  <p>If I want to add one more framing level, I just add new block and one small fix</p>
  
  <pre><code>// creating button 1
  JButton button1 = new JButton("Button 1");
  
  // creating button 2
  JButton button2 = new JButton("Button 2");
  
  // creating button 3
  JButton button3 = new JButton("Button 3");
  
  // creating panel
  JPanel panel = new JPanel();
  panel.setLayout(new FlowLayout());
  panel.add(button1);
  panel.add(button2);
  panel.add(button3);
  
  // creating another panel
  JPanel panel2 = new JPanel();
  panel2.setLayout(new FlowLayout());
  panel2.add(panel);
  
  // creating frame
  JFrame frame = new JFrame();
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  //frame.add(panel);
  frame.add(panel2); // one fix
  
  
  frame.pack();
  frame.setVisible(true);
  </code></pre>
  
  <p>Not so in <code>SWT</code>. I have to make many fixes to reassign all child creation code to new parent.</p>
  
  <pre><code>Display display = new Display();
  
  Shell shell = new Shell(display);
  shell.setLayout(new RowLayout(SWT.HORIZONTAL));
  
  
  Composite composite = new Composite(shell, SWT.NONE);
  composite.setLayout(new RowLayout(SWT.HORIZONTAL));
  
  Composite composite2 = new Composite(composite, SWT.NONE);
  composite2.setLayout(new RowLayout(SWT.HORIZONTAL));
  
  
  //Button button1 = new Button(composite, SWT.PUSH);
  Button button1 = new Button(composite2, SWT.PUSH); // fix 1
  button1.setText("Button 1");
  
  // Button button2 = new Button(composite, SWT.PUSH);
  Button button2 = new Button(composite2, SWT.PUSH); // fix 2
  button2.setText("Button 2");
  
  //Button button3 = new Button(composite, SWT.PUSH);
  Button button3 = new Button(composite2, SWT.PUSH); // fix 3
  button3.setText("Button 3");
  
  
  shell.pack();
  shell.open();
  while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
          display.sleep();
  }    
  </code></pre>
  
  <p>This is the source of potential errors.</p>
  
  <p>Is there any way to avoid this problem?</p>