Example #1
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());

    // Set the shell background to something different
    shell.setBackground(display.getSystemColor(SWT.COLOR_RED));

    // Tell the shell to give its children the same background color or image
    shell.setBackgroundMode(SWT.INHERIT_DEFAULT);

    // Optionally trying creating a patterned image for the shell background
    //    final Image backImage = new Image(display,10,10);
    //    GC gc = new GC(backImage);
    //    gc.drawLine(0,0,9,9);
    //    gc.dispose();
    //    shell.addDisposeListener(new DisposeListener() {
    //		public void widgetDisposed(DisposeEvent e) {
    //			backImage.dispose();
    //		}
    //	});
    //    shell.setBackgroundImage(backImage);

    PGroup group = new PGroup(shell, SWT.SMOOTH);
    group.setText("Example");
    group.setLayout(new FillLayout());
    group.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

    Composite groupClient = new Composite(group, SWT.NONE);
    groupClient.setBackground(display.getSystemColor(SWT.COLOR_WHITE));

    groupClient.setLayout(new GridLayout());

    Label label = new Label(groupClient, SWT.NONE);
    label.setText("Contents");
    Button button = new Button(groupClient, SWT.PUSH);
    button.setText("Contents");
    Scale scale = new Scale(groupClient, SWT.HORIZONTAL);

    shell.setSize(200, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Example #2
0
  /** Create contents of the shell. */
  protected void createContents() {
    setText("List of values");
    setSize(500, 401);

    CTabFolder tabFolder = new CTabFolder(this, SWT.BORDER);
    tabFolder.setSimple(false);
    tabFolder.setSingle(true);
    tabFolder.setBounds(10, 10, 472, 351);
    tabFolder.setSelectionBackground(
        Display.getCurrent().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT));

    CTabItem tbtmPatient = new CTabItem(tabFolder, SWT.NONE);
    tbtmPatient.setFont(SWTResourceManager.getFont("Tahoma", 9, SWT.BOLD));
    tbtmPatient.setText("Medicine");

    Composite composite = new Composite(tabFolder, SWT.NONE);
    tbtmPatient.setControl(composite);

    PGroup grpSearch = new PGroup(composite, SWT.SMOOTH);
    grpSearch.setBounds(10, 10, 446, 46);
    grpSearch.setStrategy(new RectangleGroupStrategy());
    grpSearch.setToggleRenderer(new ChevronsToggleRenderer());
    grpSearch.setText("Search");

    txtID = new Text(grpSearch, SWT.BORDER);
    txtID.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
              search();
            }
          }
        });
    txtID.setBounds(27, 24, 117, 19);

    txtName = new Text(grpSearch, SWT.BORDER);
    txtName.setBounds(194, 24, 168, 19);
    txtName.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.keyCode == 13) {
              search();
            }
          }
        });

    Label lblId = new Label(grpSearch, SWT.NONE);
    lblId.setAlignment(SWT.RIGHT);
    lblId.setBounds(10, 27, 11, 13);
    lblId.setText("ID");

    Label lblName = new Label(grpSearch, SWT.NONE);
    lblName.setText("Name");
    lblName.setAlignment(SWT.RIGHT);
    lblName.setBounds(161, 27, 27, 13);

    Button btnSearch = new Button(grpSearch, SWT.NONE);
    btnSearch.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            search();
          }
        });
    btnSearch.setBounds(368, 23, 68, 21);
    btnSearch.setText("Search");

    tblMedicine = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
    tblMedicine.setBounds(10, 62, 446, 226);
    tblMedicine.setHeaderVisible(true);
    tblMedicine.setLinesVisible(true);

    TableColumn tblcolId = new TableColumn(tblMedicine, SWT.NONE);
    tblcolId.setWidth(160);
    tblcolId.setText("ID");

    TableColumn tblcolName = new TableColumn(tblMedicine, SWT.NONE);
    tblcolName.setWidth(280);
    tblcolName.setText("Name");

    Button btnCancel = new Button(composite, SWT.NONE);
    btnCancel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnCancel.setBounds(388, 294, 68, 23);
    btnCancel.setText("Cancel");

    Button btnOk = new Button(composite, SWT.NONE);
    btnOk.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            dispose();
          }
        });
    btnOk.setBounds(314, 294, 68, 23);
    btnOk.setText("OK");
  }