示例#1
0
 private static void setShellSize(
     org.eclipse.swt.widgets.Display display, org.eclipse.swt.widgets.Shell shell) {
   org.eclipse.swt.graphics.Rectangle bounds = display.getBounds();
   org.eclipse.swt.graphics.Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
   if (size.x > bounds.width) {
     size.x = bounds.width * 9 / 10;
   }
   if (size.y > bounds.height) {
     size.y = bounds.height * 9 / 10;
   }
   shell.setSize(size);
 }
示例#2
0
 public static void main(java.lang.String[] args) {
   org.eclipse.swt.widgets.Display display = new org.eclipse.swt.widgets.Display();
   org.eclipse.swt.widgets.Shell shell = new org.eclipse.swt.widgets.Shell(display);
   shell.setText(getResourceString("window.title"));
   shell.setLayout(new org.eclipse.swt.layout.GridLayout());
   org.eclipse.swt.examples.paint.PaintExample instance =
       new org.eclipse.swt.examples.paint.PaintExample(shell);
   instance.createToolBar(shell);
   org.eclipse.swt.widgets.Composite composite =
       new org.eclipse.swt.widgets.Composite(shell, SWT.NONE);
   composite.setLayout(new org.eclipse.swt.layout.FillLayout());
   composite.setLayoutData(new org.eclipse.swt.layout.GridData(SWT.FILL, SWT.FILL, true, true));
   instance.createGUI(composite);
   instance.setDefaults();
   setShellSize(display, shell);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   instance.dispose();
 }