public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    RowLayout layout = new RowLayout(SWT.HORIZONTAL);
    layout.wrap = true;
    layout.fill = false;
    layout.justify = true;
    shell.setLayout(layout);

    Button b = new Button(shell, SWT.PUSH);
    b.setText("Button 1");
    b = new Button(shell, SWT.PUSH);

    b.setText("Button 2");

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 3");

    b = new Button(shell, SWT.PUSH);
    b.setText("Not shown");
    b.setVisible(false);
    RowData data = new RowData();
    data.exclude = true;
    b.setLayoutData(data);

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 200 high");
    data = new RowData();
    data.height = 200;
    b.setLayoutData(data);

    b = new Button(shell, SWT.PUSH);
    b.setText("Button 200 wide");
    data = new RowData();
    data.width = 200;
    b.setLayoutData(data);

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
示例#2
0
  /** build the view */
  private void buildView() {
    GridLayout gridLayout = new GridLayout(2, false);
    final Composite comp = new Composite(shell, SWT.NONE);

    shell.setLayout(new FillLayout());

    comp.setLayout(gridLayout);

    GridData gridData = new GridData();

    dataList = new List(comp, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
    gridData = new GridData();
    gridData.widthHint = 200;
    gridData.verticalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.verticalSpan = 2;
    dataList.setLayoutData(gridData);
    dataList.addListener(SWT.Selection, new ListListener());

    dataTable = new Table(comp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
    dataTable.setLinesVisible(true);
    dataTable.setHeaderVisible(true);

    gridData = new GridData();
    gridData.verticalAlignment = SWT.FILL;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.grabExcessVerticalSpace = true;
    gridData.grabExcessHorizontalSpace = true;
    dataTable.setLayoutData(gridData);

    final TableColumn column1 = new TableColumn(dataTable, SWT.NONE);
    final TableColumn column2 = new TableColumn(dataTable, SWT.NONE);

    column1.setText("Time");
    column2.setText("Value");
    column1.setWidth(180);
    column2.setWidth(270);

    Composite buttonsComp = new Composite(comp, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.heightHint = 40;
    buttonsComp.setLayoutData(gridData);
    RowLayout rowLayout = new RowLayout();
    rowLayout.type = SWT.HORIZONTAL;

    rowLayout.justify = true;
    rowLayout.pack = true;
    buttonsComp.setLayout(rowLayout);

    ButtonListener bl = new ButtonListener();

    Button refreshButton = new Button(buttonsComp, SWT.NONE);
    refreshButton.setText("Refresh");
    refreshButton.addSelectionListener(bl);

    Button exportButton = new Button(buttonsComp, SWT.NONE);
    exportButton.setText("Export");
    exportButton.addSelectionListener(bl);

    Button deleteButton = new Button(buttonsComp, SWT.NONE);
    deleteButton.setText("Delete Selection");
    deleteButton.addSelectionListener(bl);

    Button deleteallButton = new Button(buttonsComp, SWT.NONE);
    deleteallButton.setText("Delete all");
    deleteallButton.addSelectionListener(bl);
  }