<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Java1cprog</id>
		<title>Java эксперт - Вклад участника [ru]</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Java1cprog"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:%D0%92%D0%BA%D0%BB%D0%B0%D0%B4/Java1cprog"/>
		<updated>2026-05-20T07:41:29Z</updated>
		<subtitle>Вклад участника</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java_Tutorial/SWT/FormLayout&amp;diff=9258</id>
		<title>Java Tutorial/SWT/FormLayout</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java_Tutorial/SWT/FormLayout&amp;diff=9258"/>
				<updated>2010-07-25T05:19:44Z</updated>
		
		<summary type="html">&lt;p&gt;Java1cprog: Исправил опечатку в именовании класса&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==  Attaching a Control to Another Control ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The side of the control can be attached to the adjacent side of the other control (default alignment), to the opposite side of the other control, or &lt;br /&gt;
centered on the other control. Additionally, you can specify offsets.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Attaching a Control to a Position in the Parent Composite ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;To attach the control to a position in the parent composite, you need to define the position of a side of the control using a percentage value.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutAttachControl {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(50);&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    button1.setLayoutData(formData);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Attaching to the Adjacent Side of Another Control ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;By default, the control is attached to the adjacent side of the other control.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutAttachAnotherControl {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;button2&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(button1);&lt;br /&gt;
    button2.setLayoutData(formData);&lt;br /&gt;
    Button button3 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button3.setText(&amp;quot;button3&amp;quot;);&lt;br /&gt;
    formData = new FormData();&lt;br /&gt;
    formData.top = new FormAttachment(button2, 10);&lt;br /&gt;
    button3.setLayoutData(formData);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Attaching to the Specified Side of Another Control ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;The following constants are possible values for the alignment property:&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.TOP: to the top side of the specified control&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.TOP is for top and bottom alignments only.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.BOTTOM: to the bottom side of the specified control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.BOTTOM is for top and bottom alignments only.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.LEFT: to the left side of the specified control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.LEFT is for left and right alignments only.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.RIGHT: to the right side of the specified control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.RIGHT is for left and right alignments only.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.CENTER: center the control on the specified control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;org.eclipse.swt.SWT.DEFAULT: to the adjacent side of the specified control.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutAnotherControl {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;button2&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(button1);&lt;br /&gt;
    button2.setLayoutData(formData);&lt;br /&gt;
    Button button3 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button3.setText(&amp;quot;button3&amp;quot;);&lt;br /&gt;
    formData = new FormData();&lt;br /&gt;
    formData.top = new FormAttachment(button2, 10);&lt;br /&gt;
    formData.left = new FormAttachment(button2, 0, SWT.LEFT);&lt;br /&gt;
    button3.setLayoutData(formData);&lt;br /&gt;
&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Attach the bottom button to the upper-left button and the window: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Composite;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutComposite {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Composite composite = new Composite(shell, SWT.NONE);&lt;br /&gt;
    &lt;br /&gt;
    GridLayout gridLayout = new GridLayout();&lt;br /&gt;
    gridLayout.marginHeight = 0;&lt;br /&gt;
    gridLayout.marginWidth = 0;&lt;br /&gt;
    composite.setLayout(gridLayout);&lt;br /&gt;
    Button two = new Button(composite, SWT.PUSH);&lt;br /&gt;
    two.setText(&amp;quot;two&amp;quot;);&lt;br /&gt;
    GridData gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    two.setLayoutData(gridData);&lt;br /&gt;
    Button three = new Button(composite, SWT.PUSH);&lt;br /&gt;
    three.setText(&amp;quot;three&amp;quot;);&lt;br /&gt;
    gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    three.setLayoutData(gridData);&lt;br /&gt;
    Button four = new Button(composite, SWT.PUSH);&lt;br /&gt;
    four.setText(&amp;quot;four&amp;quot;);&lt;br /&gt;
    gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    four.setLayoutData(gridData);&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    Button five = new Button(shell, SWT.PUSH);&lt;br /&gt;
    five.setText(&amp;quot;five&amp;quot;);&lt;br /&gt;
    FormData data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(two, 5);&lt;br /&gt;
    data.left = new FormAttachment(0, 5);&lt;br /&gt;
    data.bottom = new FormAttachment(100, -5);&lt;br /&gt;
    data.right = new FormAttachment(100, -5);&lt;br /&gt;
    five.setLayoutData(data);&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(0, 5);&lt;br /&gt;
    data.left = new FormAttachment(two, 5);&lt;br /&gt;
    data.bottom = new FormAttachment(50, -5);&lt;br /&gt;
    data.right = new FormAttachment(100, -5);&lt;br /&gt;
    composite.setLayoutData(data);    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Center a control on another control ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutCenterAnotherControl {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;button222222222222222222222&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(button1);&lt;br /&gt;
    button2.setLayoutData(formData);&lt;br /&gt;
    Button button3 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button3.setText(&amp;quot;button3&amp;quot;);&lt;br /&gt;
    formData = new FormData();&lt;br /&gt;
    formData.top = new FormAttachment(button2, 10);&lt;br /&gt;
    formData.left = new FormAttachment(button2, 0, SWT.CENTER);&lt;br /&gt;
    button3.setLayoutData(formData);&lt;br /&gt;
&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Center control both horizontally and vertically ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutCenterControlHori {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(20);&lt;br /&gt;
    formData.top = new FormAttachment(20);&lt;br /&gt;
    button1.setLayoutData(formData);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;button number 2&amp;quot;);&lt;br /&gt;
    formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(button1, 0, SWT.CENTER);&lt;br /&gt;
    formData.top = new FormAttachment(button1, 0, SWT.CENTER);&lt;br /&gt;
    button2.setLayoutData(formData);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormData Objects and FormAttachment Objects ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;FormData objects specify how controls should be laid out.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;FormData objects define the preferred size and the attachments for four sides of the control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;FormAttachment objects control the position and size of the control.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutFormDataAttachment {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    &lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormData: width and height ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Set the preferred width and height of the control.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutFormDataWidthHeight {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.width = 100;&lt;br /&gt;
    formData.height = 200;&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    button1.setLayoutData(formData);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout: attach each other ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutAttachEachOther {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    &lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(20);&lt;br /&gt;
    formData.top = new FormAttachment(20);&lt;br /&gt;
    button1.setLayoutData(formData);    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;button number 2&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(button1, 0, SWT.CENTER);&lt;br /&gt;
    formData.top = new FormAttachment(button1, 0, SWT.CENTER);&lt;br /&gt;
    button2.setLayoutData(formData);&lt;br /&gt;
    &lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    // Set up the event loop.&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        // If no more entries in event queue&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout: attach with left and right margin ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Specifies the size of the vertical margin in pixels. &lt;br /&gt;
The default value is 0.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutLeftRight {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    final Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display, SWT.SHELL_TRIM);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    &lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(20);&lt;br /&gt;
    formData.top = new FormAttachment(20);&lt;br /&gt;
    button1.setLayoutData(formData);    &lt;br /&gt;
    &lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    // Set up the event loop.&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        // If no more entries in event queue&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout Complex ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutComplex {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    FormLayout layout = new FormLayout();&lt;br /&gt;
    shell.setLayout(layout);&lt;br /&gt;
    Button one = new Button(shell, SWT.PUSH);&lt;br /&gt;
    one.setText(&amp;quot;One&amp;quot;);&lt;br /&gt;
    FormData data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(0, 5);&lt;br /&gt;
    data.left = new FormAttachment(0, 5);&lt;br /&gt;
    data.bottom = new FormAttachment(50, -5);&lt;br /&gt;
    data.right = new FormAttachment(50, -5);&lt;br /&gt;
    one.setLayoutData(data);&lt;br /&gt;
    Composite composite = new Composite(shell, SWT.NONE);&lt;br /&gt;
    GridLayout gridLayout = new GridLayout();&lt;br /&gt;
    gridLayout.marginHeight = 20;&lt;br /&gt;
    gridLayout.marginWidth = 20;&lt;br /&gt;
    composite.setLayout(gridLayout);&lt;br /&gt;
    Button two = new Button(composite, SWT.PUSH);&lt;br /&gt;
    two.setText(&amp;quot;two&amp;quot;);&lt;br /&gt;
    GridData gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    two.setLayoutData(gridData);&lt;br /&gt;
    Button three = new Button(composite, SWT.PUSH);&lt;br /&gt;
    three.setText(&amp;quot;three&amp;quot;);&lt;br /&gt;
    gridData = new GridData(GridData.FILL_HORIZONTAL);&lt;br /&gt;
    three.setLayoutData(gridData);&lt;br /&gt;
    Button four = new Button(composite, SWT.PUSH);&lt;br /&gt;
    four.setText(&amp;quot;four&amp;quot;);&lt;br /&gt;
    gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    four.setLayoutData(gridData);&lt;br /&gt;
    data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(0, 15);&lt;br /&gt;
    data.left = new FormAttachment(one, 25);&lt;br /&gt;
    data.bottom = new FormAttachment(50, -15);&lt;br /&gt;
    data.right = new FormAttachment(100, -25);&lt;br /&gt;
    composite.setLayoutData(data);&lt;br /&gt;
    Button five = new Button(shell, SWT.PUSH);&lt;br /&gt;
    five.setText(&amp;quot;five&amp;quot;);&lt;br /&gt;
    data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(one, 5);&lt;br /&gt;
    data.left = new FormAttachment(0, 5);&lt;br /&gt;
    data.bottom = new FormAttachment(100, -5);&lt;br /&gt;
    data.right = new FormAttachment(100, -5);&lt;br /&gt;
    five.setLayoutData(data);&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout example snippet: center a label and single line text using a form layout ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * FormLayout example snippet: center a label and single line text using a form layout&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
import org.eclipse.swt.widgets.Text;&lt;br /&gt;
public class FormLayoutSingleLine {&lt;br /&gt;
public static void main (String [] args) {&lt;br /&gt;
  Display display = new Display ();&lt;br /&gt;
  Shell shell = new Shell (display);&lt;br /&gt;
  Label label = new Label (shell, SWT.NONE | SWT.BORDER);&lt;br /&gt;
  label.setText (&amp;quot;Name&amp;quot;);&lt;br /&gt;
  &lt;br /&gt;
  Text text = new Text (shell, SWT.NONE);&lt;br /&gt;
  FormLayout layout = new FormLayout ();&lt;br /&gt;
  layout.marginWidth = layout.marginHeight = 5;&lt;br /&gt;
  shell.setLayout (layout);&lt;br /&gt;
  FormData data = new FormData (200, SWT.DEFAULT);&lt;br /&gt;
  text.setLayoutData (data);&lt;br /&gt;
  data.left = new FormAttachment (label, 5);&lt;br /&gt;
  data.top = new FormAttachment (label, 0, SWT.CENTER);&lt;br /&gt;
  &lt;br /&gt;
  shell.open ();&lt;br /&gt;
  while (!shell.isDisposed ()) {&lt;br /&gt;
    if (!display.readAndDispatch ()) display.sleep ();&lt;br /&gt;
  }&lt;br /&gt;
  display.dispose ();&lt;br /&gt;
}&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout example snippet: create a simple dialog using form layout ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * FormLayout example snippet: create a simple dialog using form layout&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.List;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class DialogLayoutDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    Label label = new Label(shell, SWT.WRAP);&lt;br /&gt;
    label.setText(&amp;quot;This is a long text string that will wrap when the dialog is resized.&amp;quot;);&lt;br /&gt;
    List list = new List(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    list.setItems(new String[] { &amp;quot;Item 1&amp;quot;, &amp;quot;Item 2&amp;quot; });&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;OK&amp;quot;);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    final int insetX = 4, insetY = 4;&lt;br /&gt;
    FormLayout formLayout = new FormLayout();&lt;br /&gt;
    formLayout.marginWidth = insetX;&lt;br /&gt;
    formLayout.marginHeight = insetY;&lt;br /&gt;
    shell.setLayout(formLayout);&lt;br /&gt;
    Point size = label.ruputeSize(SWT.DEFAULT, SWT.DEFAULT);&lt;br /&gt;
    final FormData labelData = new FormData(size.x, SWT.DEFAULT);&lt;br /&gt;
    labelData.left = new FormAttachment(0, 0);&lt;br /&gt;
    labelData.right = new FormAttachment(100, 0);&lt;br /&gt;
    label.setLayoutData(labelData);&lt;br /&gt;
    shell.addListener(SWT.Resize, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Rectangle rect = shell.getClientArea();&lt;br /&gt;
        labelData.width = rect.width - insetX * 2;&lt;br /&gt;
        shell.layout();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    FormData button2Data = new FormData();&lt;br /&gt;
    button2Data.right = new FormAttachment(100, -insetX);&lt;br /&gt;
    button2Data.bottom = new FormAttachment(100, 0);&lt;br /&gt;
    button2.setLayoutData(button2Data);&lt;br /&gt;
    FormData button1Data = new FormData();&lt;br /&gt;
    button1Data.right = new FormAttachment(button2, -insetX);&lt;br /&gt;
    button1Data.bottom = new FormAttachment(100, 0);&lt;br /&gt;
    button1.setLayoutData(button1Data);&lt;br /&gt;
    FormData listData = new FormData();&lt;br /&gt;
    listData.left = new FormAttachment(0, 0);&lt;br /&gt;
    listData.right = new FormAttachment(100, 0);&lt;br /&gt;
    listData.top = new FormAttachment(label, insetY);&lt;br /&gt;
    listData.bottom = new FormAttachment(button2, -insetY);&lt;br /&gt;
    list.setLayoutData(listData);&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout example snippet: create a simple OK/CANCEL dialog using form layout ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
/*******************************************************************************&lt;br /&gt;
 * Copyright (c) 2000, 2004 IBM Corporation and others.&lt;br /&gt;
 * All rights reserved. This program and the accompanying materials&lt;br /&gt;
 * are made available under the terms of the Eclipse Public License v1.0&lt;br /&gt;
 * which accompanies this distribution, and is available at&lt;br /&gt;
 * http://www.eclipse.org/legal/epl-v10.html&lt;br /&gt;
 *&lt;br /&gt;
 * Contributors:&lt;br /&gt;
 *     IBM Corporation - initial API and implementation&lt;br /&gt;
 *******************************************************************************/&lt;br /&gt;
//package org.eclipse.swt.snippets;&lt;br /&gt;
/*&lt;br /&gt;
 * FormLayout example snippet: create a simple OK/CANCEL dialog using form layout&lt;br /&gt;
 *&lt;br /&gt;
 * For a list of all SWT example snippets see&lt;br /&gt;
 * http://www.eclipse.org/swt/snippets/&lt;br /&gt;
 */&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class DialogOKCancelFormLayout {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    Shell dialog = new Shell(shell, SWT.DIALOG_TRIM);&lt;br /&gt;
    Label label = new Label(dialog, SWT.NONE);&lt;br /&gt;
    label.setText(&amp;quot;Exit the application?&amp;quot;);&lt;br /&gt;
    Button okButton = new Button(dialog, SWT.PUSH);&lt;br /&gt;
    okButton.setText(&amp;quot;&amp;amp;OK&amp;quot;);&lt;br /&gt;
    Button cancelButton = new Button(dialog, SWT.PUSH);&lt;br /&gt;
    cancelButton.setText(&amp;quot;&amp;amp;Cancel&amp;quot;);&lt;br /&gt;
    FormLayout form = new FormLayout();&lt;br /&gt;
    form.marginWidth = form.marginHeight = 8;&lt;br /&gt;
    dialog.setLayout(form);&lt;br /&gt;
    FormData okData = new FormData();&lt;br /&gt;
    okData.top = new FormAttachment(label, 8);&lt;br /&gt;
    okButton.setLayoutData(okData);&lt;br /&gt;
    FormData cancelData = new FormData();&lt;br /&gt;
    cancelData.left = new FormAttachment(okButton, 8);&lt;br /&gt;
    cancelData.top = new FormAttachment(okButton, 0, SWT.TOP);&lt;br /&gt;
    cancelButton.setLayoutData(cancelData);&lt;br /&gt;
    dialog.setDefaultButton(okButton);&lt;br /&gt;
    dialog.pack();&lt;br /&gt;
    dialog.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  FormLayout: spacing ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Specifies the number of pixels between the edge of one control and the edge of its neighboring control. &lt;br /&gt;
The default value is 0.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Specify attachments for all four sides of a control. ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutAttachFourSidesControl {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(50);&lt;br /&gt;
    formData.right = new FormAttachment(100);&lt;br /&gt;
    formData.top = new FormAttachment(50);&lt;br /&gt;
    formData.bottom = new FormAttachment(100);&lt;br /&gt;
    button1.setLayoutData(formData);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Specify the offset of the control side from the attachment position ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;Positive value: the control side is offset to the right of or below the attachment position.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;Negative value: the control side is offset to the left of or above the attachment position.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutControlOffsetAttachment {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    Point size = button1.ruputeSize(SWT.DEFAULT, SWT.DEFAULT);&lt;br /&gt;
    int offset = size.x / 2;&lt;br /&gt;
    FormData formData = new FormData();&lt;br /&gt;
    formData.left = new FormAttachment(50, -1 * offset);&lt;br /&gt;
    button1.setLayoutData(formData);&lt;br /&gt;
&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Start with the upper-left button, attach the top and left edges to the window,  offsetting by five pixels: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutFormAttachmentSetButton {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    FormLayout layout = new FormLayout();&lt;br /&gt;
    layout.marginHeight = 5;&lt;br /&gt;
    layout.marginWidth = 10;&lt;br /&gt;
    shell.setLayout(layout);&lt;br /&gt;
    Button one = new Button(shell, SWT.PUSH);&lt;br /&gt;
    one.setText(&amp;quot;One&amp;quot;);&lt;br /&gt;
    FormData data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(0, 5);&lt;br /&gt;
    data.left = new FormAttachment(0, 5);&lt;br /&gt;
    data.bottom = new FormAttachment(50, -5);&lt;br /&gt;
    data.right = new FormAttachment(50, -5);&lt;br /&gt;
    one.setLayoutData(data);    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  To configure the attachment of each side ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;top: Specifies the attachment of the top of the control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;bottom: Specifies the attachment of the bottom of the control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;left: Specifies the attachment of the left of the control.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;right: Specifies the attachment of the right of the control.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;A FormAttachment object specifies the attachment of a specific side of a control. &lt;br /&gt;
You can attach a side to a position in the parent composite, to the adjacent side of another control, to the opposite side of another control, or centered on another control.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  To create the upper-right three buttons, you reason that you can put them all in a composite with a grid layout, and attach the composite to your first button: ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.layout.GridData;&lt;br /&gt;
import org.eclipse.swt.layout.GridLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.ruposite;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutComposite {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Composite composite = new Composite(shell, SWT.NONE);&lt;br /&gt;
    &lt;br /&gt;
    GridLayout gridLayout = new GridLayout();&lt;br /&gt;
    gridLayout.marginHeight = 0;&lt;br /&gt;
    gridLayout.marginWidth = 0;&lt;br /&gt;
    composite.setLayout(gridLayout);&lt;br /&gt;
    Button two = new Button(composite, SWT.PUSH);&lt;br /&gt;
    two.setText(&amp;quot;two&amp;quot;);&lt;br /&gt;
    GridData gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    two.setLayoutData(gridData);&lt;br /&gt;
    Button three = new Button(composite, SWT.PUSH);&lt;br /&gt;
    three.setText(&amp;quot;three&amp;quot;);&lt;br /&gt;
    gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    three.setLayoutData(gridData);&lt;br /&gt;
    Button four = new Button(composite, SWT.PUSH);&lt;br /&gt;
    four.setText(&amp;quot;four&amp;quot;);&lt;br /&gt;
    gridData = new GridData(GridData.FILL_BOTH);&lt;br /&gt;
    four.setLayoutData(gridData);&lt;br /&gt;
    &lt;br /&gt;
    FormData data = new FormData();&lt;br /&gt;
    data.top = new FormAttachment(0, 5);&lt;br /&gt;
    data.left = new FormAttachment(two, 5);&lt;br /&gt;
    data.bottom = new FormAttachment(50, -5);&lt;br /&gt;
    data.right = new FormAttachment(100, -5);&lt;br /&gt;
    composite.setLayoutData(data);    &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Use FormLayout to layout a dialog ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.graphics.Point;&lt;br /&gt;
import org.eclipse.swt.graphics.Rectangle;&lt;br /&gt;
import org.eclipse.swt.layout.FormAttachment;&lt;br /&gt;
import org.eclipse.swt.layout.FormData;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Event;&lt;br /&gt;
import org.eclipse.swt.widgets.Label;&lt;br /&gt;
import org.eclipse.swt.widgets.List;&lt;br /&gt;
import org.eclipse.swt.widgets.Listener;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutDialogDemo {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    Label label = new Label(shell, SWT.WRAP);&lt;br /&gt;
    label.setText(&amp;quot;Some text for your dialog.&amp;quot;);&lt;br /&gt;
    List list = new List(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);&lt;br /&gt;
    list.setItems(new String[] { &amp;quot;Item 1&amp;quot;, &amp;quot;Item2&amp;quot; });&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;Ok&amp;quot;);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;Cancel&amp;quot;);&lt;br /&gt;
    final int insetX = 4, insetY = 4;&lt;br /&gt;
    FormLayout formLayout = new FormLayout();&lt;br /&gt;
    formLayout.marginWidth = insetX;&lt;br /&gt;
    formLayout.marginHeight = insetY;&lt;br /&gt;
    shell.setLayout(formLayout);&lt;br /&gt;
    Point size = label.ruputeSize(SWT.DEFAULT, SWT.DEFAULT);&lt;br /&gt;
    final FormData labelData = new FormData(size.x, SWT.DEFAULT);&lt;br /&gt;
    labelData.left = new FormAttachment(0, 0);&lt;br /&gt;
    labelData.right = new FormAttachment(100, 0);&lt;br /&gt;
    label.setLayoutData(labelData);&lt;br /&gt;
    shell.addListener(SWT.Resize, new Listener() {&lt;br /&gt;
      public void handleEvent(Event e) {&lt;br /&gt;
        Rectangle rect = shell.getClientArea();&lt;br /&gt;
        labelData.width = rect.width - insetX * 2;&lt;br /&gt;
        shell.layout();&lt;br /&gt;
      }&lt;br /&gt;
    });&lt;br /&gt;
    FormData button2Data = new FormData();&lt;br /&gt;
    button2Data.right = new FormAttachment(100, -insetX);&lt;br /&gt;
    button2Data.bottom = new FormAttachment(100, 0);&lt;br /&gt;
    button2.setLayoutData(button2Data);&lt;br /&gt;
    FormData button1Data = new FormData();&lt;br /&gt;
    button1Data.right = new FormAttachment(button2, -insetX);&lt;br /&gt;
    button1Data.bottom = new FormAttachment(100, 0);&lt;br /&gt;
    button1.setLayoutData(button1Data);&lt;br /&gt;
    FormData listData = new FormData();&lt;br /&gt;
    listData.left = new FormAttachment(0, 0);&lt;br /&gt;
    listData.right = new FormAttachment(100, 0);&lt;br /&gt;
    listData.top = new FormAttachment(label, insetY);&lt;br /&gt;
    listData.bottom = new FormAttachment(button2, -insetY);&lt;br /&gt;
    list.setLayoutData(listData);&lt;br /&gt;
    shell.pack();&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch())&lt;br /&gt;
        display.sleep();&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Using FormLayouts ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;OL&amp;gt;&amp;lt;LI&amp;gt;A FormLayout uses FormAttachment objects to configure the left, right, top, and bottom edge of a widget.&amp;lt;/LI&amp;gt;&amp;lt;LI&amp;gt;A FormAttachment attaches a side of the control either to a position in the parent composite or to one of its sibling controls within the layout.&amp;lt;/LI&amp;gt;&amp;lt;/OL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==  Without FormAttachment objects ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p&amp;gt;Without FormAttachment objects, the control will be attached to the top-left edges of the parent composite by default.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Button will stack.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
import org.eclipse.swt.SWT;&lt;br /&gt;
import org.eclipse.swt.layout.FormLayout;&lt;br /&gt;
import org.eclipse.swt.widgets.Button;&lt;br /&gt;
import org.eclipse.swt.widgets.Display;&lt;br /&gt;
import org.eclipse.swt.widgets.Shell;&lt;br /&gt;
public class FormLayoutFormAttachment {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    Display display = new Display();&lt;br /&gt;
    final Shell shell = new Shell(display);&lt;br /&gt;
    shell.setLayout(new FormLayout());&lt;br /&gt;
    Button button1 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button1.setText(&amp;quot;button1&amp;quot;);&lt;br /&gt;
    Button button2 = new Button(shell, SWT.PUSH);&lt;br /&gt;
    button2.setText(&amp;quot;button2&amp;quot;);&lt;br /&gt;
    shell.setSize(450, 400);&lt;br /&gt;
    shell.open();&lt;br /&gt;
    while (!shell.isDisposed()) {&lt;br /&gt;
      if (!display.readAndDispatch()) {&lt;br /&gt;
        display.sleep();&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
    display.dispose();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
		<author><name>Java1cprog</name></author>	</entry>

	</feed>