Пример #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();
  }