import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Shell; public class SnippetWithBuilder { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); createComposite(shell); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } private static final int LIST_MARGIN = 10; private static final int HEADER_MARGIN = 5; private static final int ARROW_BUTTON_MARGIN = 3; private static void createComposite(Composite parent) { parent.setLayout(new FormLayout()); Label header1 = new Label(parent, SWT.NONE); header1.setText("Available"); List list1 = new List(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); Button right = new Button(parent, SWT.ARROW | SWT.RIGHT); Label moveLabel = new Label(parent, SWT.NONE); moveLabel.setText("Move"); Button left = new Button(parent, SWT.ARROW | SWT.LEFT); Label header2 = new Label(parent, SWT.NONE); header2.setText("Selected"); List list2 = new List(parent, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); FormDataBuilder.position(header1).top().left(); FormDataBuilder.position(list1).top(header1, HEADER_MARGIN).bottom().left().right(moveLabel, LIST_MARGIN); FormDataBuilder.position(moveLabel).centerHorizontally().centerVertically(); FormDataBuilder.position(right).centerHorizontally().bottom(moveLabel, ARROW_BUTTON_MARGIN); FormDataBuilder.position(left).centerHorizontally().top(moveLabel, ARROW_BUTTON_MARGIN); FormDataBuilder.position(header2).top().left(list2, 0, SWT.LEFT); FormDataBuilder.position(list2).top(header2, HEADER_MARGIN).bottom().left(moveLabel, LIST_MARGIN).right(); } }