protected void openDialog() {

    if (Const.isWindows()) {
      shell.setSize(653, 671);
    }
    if (Const.isLinux()) {
      shell.setSize(740, 678);
    }
    if (Const.isOSX()) {
      shell.setSize(653, 678);
    }

    // Set the focus on the OK button
    wOK.setFocus();
    shell.open();

    Rectangle shellBounds = getParent().getBounds();
    Point dialogSize = shell.getSize();

    shell.setLocation(
        shellBounds.x + (shellBounds.width - dialogSize.x) / 2,
        shellBounds.y + (shellBounds.height - dialogSize.y) / 2);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
示例#2
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new RowLayout());

    DateTime calendar = new DateTime(shell, SWT.CALENDAR);
    calendar.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.out.println("calendar date changed");
          }
        });

    DateTime time = new DateTime(shell, SWT.TIME);
    time.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            System.out.println("time changed");
          }
        });

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
  /** ********************* CONSTRUCTOR **************************** */
  public RyanairInspector2GUI() {

    bufferNavegadores = new Buffer(new CircularQueue(SIZE));
    for (Navegador n : navegadores) {
      bufferNavegadores.Put(n);
    }

    bufferVuelos = new Buffer(new CircularQueue(SIZE));
    System.out.println(rutaActual);
    System.out.println("-- Empieza lectura fichero --");
    vuelos = UtilsIO.leerFicheroDatosConsultaVuelos(rutaActual + nomFichConsultas);
    for (Vuelo v : vuelos) {
      bufferVuelos.Put(v);
      System.out.println(v.toString());
    }
    System.out.println("-- Termina lectura fichero --");

    /*__ CREAMOS UNA INSTANCIA PARA CAPTURAR UN VUELO */
    unvueloRyanair = new RyanairInspector2();

    creaContenidos();

    // Iniciamos la carga de la pagina
    iniciaCaptura(table);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
    // System.out.println("despues de dispose");

  }
示例#4
0
  public static void main(String[] args) {
    LoggerContext loggerContext = new LoggerContext();
    Display display = new Display();
    ResourceUtil.init(display);
    Shell shell = new Shell(display);
    final Tree tree = new Tree(shell, SWT.BORDER);
    Rectangle clientArea = shell.getClientArea();
    tree.setBounds(clientArea.x, clientArea.y, 200, 200);

    LoggerTree loggerTree = new LoggerTree(loggerContext, tree);
    tree.setMenu(TreeMenuBuilder.buildTreeMenu(loggerTree, null));
    loggerTree.update("com.foo.Bar");
    loggerTree.update("com.foo.Bar");

    loggerContext.getLogger("org.apache.struts").setLevel(Level.ERROR);

    loggerTree.update("org.apache.struts.BlahAction");

    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
示例#5
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell();

    LightweightSystem lws = new LightweightSystem(shell);

    Figure panel = new Figure();
    panel.setLayoutManager(new FlowLayout());
    panel.setBackgroundColor(ColorConstants.white);

    MouseMotionListener listener =
        new MouseMotionListener.Stub() {
          public void mouseEntered(MouseEvent me) {
            ((Shape) me.getSource()).setBackgroundColor(ColorConstants.yellow);
          }

          public void mouseExited(MouseEvent me) {
            ((Shape) me.getSource()).setBackgroundColor(ColorConstants.white);
          }
        };

    for (int i = 1; i <= 4; i++) {
      Ellipse e = new Ellipse();
      e.setFill(true);
      e.setPreferredSize(new Dimension(20 + 10 * i + i % 2, 60 - 10 * i + i / 2));
      e.addMouseMotionListener(listener);
      panel.add(e);
    }

    lws.setContents(panel);
    shell.setSize(400, 300);
    shell.open();

    while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();
  }
 public static void main(String[] args) {
   final Display display = new Display();
   final Shell shell = new Shell(display);
   shell.setLayout(new FillLayout());
   final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
   styledText.setText(text);
   FontData data = display.getSystemFont().getFontData()[0];
   Font font = new Font(display, data.getName(), 16, SWT.BOLD);
   styledText.setFont(font);
   styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE));
   styledText.addListener(
       SWT.Resize,
       new Listener() {
         public void handleEvent(Event event) {
           Rectangle rect = styledText.getClientArea();
           Image newImage = new Image(display, 1, Math.max(1, rect.height));
           GC gc = new GC(newImage);
           gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
           gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
           gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true);
           gc.dispose();
           styledText.setBackgroundImage(newImage);
           if (oldImage != null) oldImage.dispose();
           oldImage = newImage;
         }
       });
   shell.setSize(700, 400);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   if (oldImage != null) oldImage.dispose();
   font.dispose();
   display.dispose();
 }
示例#7
0
  public void run(String trace) throws JDOMException, IOException, JniException {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Flightbox");
    shell.setSize(800, 800);
    shell.setLayout(new FillLayout(SWT.VERTICAL));

    IntervalView widget = new IntervalView(shell, SWT.NONE);
    VersionizedStack<String> stack = new VersionizedStack<String>();
    int i;
    int max = 1000;
    for (i = 0; i < max; i++) {
      long disp = i * 100;
      stack.push("FOO", 10L + disp);
      stack.push("BAR", 20L + disp);
      stack.pop(30L + disp);
      stack.pop(40L + disp);
    }

    widget.setStack(stack);

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    shell.dispose();
  }
  /** @param args */
  public static void main(String[] args) {
    Display display = new Display();
    JFaceResources.getImageRegistry()
        .put(
            "IMG_1",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/cancel.png")));
    JFaceResources.getImageRegistry()
        .put(
            "IMG_2",
            ImageDescriptor.createFromURL(
                Snippet033CellEditorPerRowPre33.class
                    .getClassLoader()
                    .getResource("org/eclipse/jface/snippets/dialogs/filesave.png")));
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    new Snippet033CellEditorPerRowPre33(shell);
    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
示例#9
0
  private static void main() throws FileNotFoundException {
    // デフォルトDisplayを使用してシェルを作成
    try {
      shell.setSize(100, 100); // シェルのサイズを指定

      // 作成したシェルを使用したLightweightSystemの作成
      LightweightSystem lws = new LightweightSystem(shell);

      // ルート・フィギュアの作成
      IFigure panel = new Figure();
      panel.setLayoutManager(new ToolbarLayout());

      initialize(panel);

      // ルート・フィギュアの登録
      lws.setContents(panel);

      // 以下は、その他のSWTアプリケーションと同様
      shell.open();

      Display display = Display.getDefault();
      while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }

    } finally {
      if (image != null) {
        image.dispose();
      }
    }
  }
  public static void main(String[] args) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setText("SWT and Swing DND Example");
    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);

    Text swtText = new Text(shell, SWT.BORDER);
    swtText.setText("SWT Text");
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    swtText.setLayoutData(data);
    setDragDrop(swtText);

    Composite comp = new Composite(shell, SWT.EMBEDDED);
    java.awt.Frame frame = SWT_AWT.new_Frame(comp);
    JTextField swingText = new JTextField(40);
    swingText.setText("Swing Text");
    swingText.setDragEnabled(true);
    frame.add(swingText);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.heightHint = swingText.getPreferredSize().height;
    comp.setLayoutData(data);

    shell.setSize(400, 200);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
示例#11
0
  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());
    final ScrolledComposite sc =
        new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
    Composite c = new Composite(sc, SWT.NONE);
    c.setLayout(new GridLayout(10, true));
    for (int i = 0; i < 300; i++) {
      Button b = new Button(c, SWT.PUSH);
      b.setText("Button " + i);
    }
    sc.setContent(c);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    sc.setShowFocusedControl(true);

    shell.setSize(300, 500);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
示例#12
0
 @Override
 public void run() {
   // use my class for library loading
   try {
     Display display = Display.getDefault();
     final Shell splash = createSplash(display);
     final Shell content = new Shell(display);
     splash.open();
     display.asyncExec(
         new Runnable() {
           @Override
           public void run() {
             runContent(content);
             content.open();
             splash.close();
           }
         });
     while (!splash.isDisposed() || !content.isDisposed()) {
       if (!display.readAndDispatch()) display.sleep();
     }
     if (sandbox != null) sandbox.shutdown();
     display.dispose();
   } catch (Throwable e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     System.err.flush();
     System.out.flush();
     System.exit(0);
   }
 }
示例#13
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Combo combo = new Combo(shell, SWT.NONE);
   combo.setItems(new String[] {"A-1", "B-1", "C-1"});
   Text text = new Text(shell, SWT.SINGLE | SWT.BORDER);
   text.setText("some text");
   combo.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   text.addListener(
       SWT.DefaultSelection,
       new Listener() {
         public void handleEvent(Event e) {
           System.out.println(e.widget + " - Default Selection");
         }
       });
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  /** Debug only */
  private static void drawModel(final SWTArranger a) {
    final Display d = new Display();
    Shell s = new Shell(d);
    s.setSize(500, 500);

    s.setLayout(new FillLayout());

    Canvas canvas = new Canvas(s, SWT.NONE);
    canvas.setSize(500, 500);
    canvas.setLocation(20, 20);
    canvas.addPaintListener(
        new PaintListener() {

          @Override
          public void paintControl(PaintEvent e) {
            Color c = new Color(d, 0x00, 0x00, 0x00);
            GC gc = e.gc;
            gc.setBackground(c);
            for (Block r : a.blocks) {
              gc.fillRectangle(r.x, r.y, r.width, r.height);
            }
            c.dispose();
            gc.dispose();
          }
        });
    s.pack();
    s.open();

    while (!s.isDisposed()) {
      if (!d.readAndDispatch()) {
        d.sleep();
      }
    }
    d.dispose();
  }
示例#15
0
  public static void view(DrawModel d) {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
    Frame baseFrame = SWT_AWT.new_Frame(composite);

    baseFrame.setBounds(0, 0, 800, 600);

    Java3DViewer viewer = new Java3DViewer(baseFrame, d);
    baseFrame.add(viewer);

    shell.open();

    d.setFaceColor(Color.GREEN);
    d.circle(0.9);
    //		viewer.draw(d);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    baseFrame.dispose();
    shell.dispose();
    composite.dispose();
    display.dispose();
    System.exit(0);
  }
示例#16
0
  public Main(String args[]) {
    //   must be before display is created (on Macs at least)
    Display.setAppName("BrailleZephyr");

    Display display = Display.getDefault();

    //   needed to catch Quit (Command-Q) on Macs
    display.addListener(SWT.Close, new CloseHandler());

    shell = new Shell(display);
    shell.setLayout(new FillLayout());
    shell.setText("BrailleZephyr");
    shell.addShellListener(new ShellHandler());

    bzStyledText = new BZStyledText(shell);
    bzFile = new BZFile(bzStyledText);
    bzSettings = new BZSettings(bzStyledText);
    new BZMenu(bzStyledText, bzFile, bzSettings);

    //   assume any argument is a file to open
    if (args.length > 0) bzFile.openFile(args[0]);

    shell.open();
    while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();

    display.dispose();
  }
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setText("StyledText with underline and strike through");
   shell.setLayout(new FillLayout());
   StyledText text = new StyledText(shell, SWT.BORDER);
   text.setText("0123456789 ABCDEFGHIJKLM NOPQRSTUVWXYZ");
   // make 0123456789 appear underlined
   StyleRange style1 = new StyleRange();
   style1.start = 0;
   style1.length = 10;
   style1.underline = true;
   text.setStyleRange(style1);
   // make ABCDEFGHIJKLM have a strike through
   StyleRange style2 = new StyleRange();
   style2.start = 11;
   style2.length = 13;
   style2.strikeout = true;
   text.setStyleRange(style2);
   // make NOPQRSTUVWXYZ appear underlined and have a strike through
   StyleRange style3 = new StyleRange();
   style3.start = 25;
   style3.length = 13;
   style3.underline = true;
   style3.strikeout = true;
   text.setStyleRange(style3);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  public static void main(final String[] args) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final CompositeTable table = new CompositeTable(shell, SWT.NONE);
    new Header(table, SWT.NONE);
    new Row(table, SWT.NONE);
    table.setRunTime(true);

    final ICompositeTableRidget ridget =
        (ICompositeTableRidget) SwtRidgetFactory.createRidget(table);
    final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class);
    ridget.bindToModel(input, Person.class, RowRidget.class);
    ridget.updateFromModel();

    shell.setSize(400, 160);
    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    display.dispose();
  }
示例#19
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.setLayout(new org.eclipse.swt.layout.FillLayout());
   shell.setText(getResourceString("window.title"));
   java.io.InputStream stream =
       (org.eclipse.swt.examples.browserexample.BrowserExample.class)
           .getResourceAsStream(iconLocation);
   org.eclipse.swt.graphics.Image icon = new org.eclipse.swt.graphics.Image(display, stream);
   shell.setImage(icon);
   try {
     stream.close();
   } catch (java.io.IOException e) {
     e.printStackTrace();
   }
   org.eclipse.swt.examples.browserexample.BrowserExample app =
       new org.eclipse.swt.examples.browserexample.BrowserExample(shell, true);
   app.setShellDecoration(icon, true);
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) {
       display.sleep();
     }
   }
   icon.dispose();
   app.dispose();
   display.dispose();
 }
    public Shell createShell() {
      // Build a UI
      Display display = Display.getDefault();
      Shell shell = new Shell(display);
      duckFamily = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION);
      duckFamily.setHeaderVisible(true);
      GridDataFactory.defaultsFor(duckFamily).span(2, 1).applyTo(duckFamily);
      createColumn("Name");
      createColumn("Mother");
      createColumn("Father");
      createColumn("Grandmother");
      duckFamily.setLinesVisible(true);

      new Label(shell, SWT.NONE).setText("Name:");
      nameText = new Text(shell, SWT.BORDER);
      GridDataFactory.defaultsFor(nameText).grab(true, false).applyTo(nameText);

      new Label(shell, SWT.NONE).setText("Mother:");
      motherCombo = new Combo(shell, SWT.READ_ONLY);

      new Label(shell, SWT.NONE).setText("Father:");
      fatherCombo = new Combo(shell, SWT.READ_ONLY);

      DataBindingContext bindingContext = new DataBindingContext();
      bindGUI(bindingContext);

      GridLayoutFactory.swtDefaults().numColumns(2).applyTo(shell);
      // Open and return the Shell
      shell.setSize(500, 300);
      shell.open();
      return shell;
    }
  protected void runTestAGL(GLProfile glprofile) throws InterruptedException {
    GLData gldata = new GLData();
    gldata.doubleBuffer = true;
    // need SWT.NO_BACKGROUND to prevent SWT from clearing the window
    // at the wrong times (we use glClear for this instead)
    final GLCanvas glcanvas = new GLCanvas(composite, SWT.NO_BACKGROUND, gldata);
    Assert.assertNotNull(glcanvas);
    glcanvas.setCurrent();
    final GLContext glcontext = GLDrawableFactory.getFactory(glprofile).createExternalGLContext();
    Assert.assertNotNull(glcontext);

    // fix the viewport when the user resizes the window
    glcanvas.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event event) {
            Rectangle rectangle = glcanvas.getClientArea();
            glcanvas.setCurrent();
            glcontext.makeCurrent();
            GL2ES1 gl = glcontext.getGL().getGL2ES1();
            OneTriangle.setup(gl, rectangle.width, rectangle.height);
            glcontext.release();
            System.err.println("resize");
          }
        });

    // draw the triangle when the OS tells us that any part of the window needs drawing
    glcanvas.addPaintListener(
        new PaintListener() {
          public void paintControl(PaintEvent paintevent) {
            Rectangle rectangle = glcanvas.getClientArea();
            glcanvas.setCurrent();
            glcontext.makeCurrent();
            GL2ES1 gl = glcontext.getGL().getGL2ES1();
            OneTriangle.render(gl, rectangle.width, rectangle.height);
            glcanvas.swapBuffers();
            glcontext.release();
            System.err.println("paint");
          }
        });

    shell.setText(getClass().getName());
    shell.setSize(640, 480);
    shell.open();

    long lStartTime = System.currentTimeMillis();
    long lEndTime = lStartTime + duration;
    try {
      while ((System.currentTimeMillis() < lEndTime) && !glcanvas.isDisposed()) {
        if (!display.readAndDispatch()) {
          // blocks on linux .. display.sleep();
          Thread.sleep(10);
        }
      }
    } catch (Throwable throwable) {
      throwable.printStackTrace();
      Assume.assumeNoException(throwable);
    }
    glcanvas.dispose();
  }
  @Before
  public void setUp() {
    display = Display.getDefault();
    shell = new Shell(display);
    shell.setLayout(new FillLayout());

    SquareButton.SquareButtonBuilder builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("one").setToggleable(true);
    toggleOne = builder.build();

    builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("two").setToggleable(true);
    toggleTwo = builder.build();

    builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("three").setToggleable(true);
    toggleThree = builder.build();

    builder = new SquareButton.SquareButtonBuilder();
    builder.setParent(shell).setText("non toggle");
    nonToggled = builder.build();

    group = new SquareButtonGroup(toggleOne, toggleTwo, toggleThree, nonToggled);

    shell.open();
  }
  /** Open the window */
  public void open() throws Exception {

    final Display display = Display.getDefault();
    createContents();

    _setWndPosition();
    _initXPCOM();
    _initFields();
    _initJSErrorHook();

    m_shell.open();
    m_shell.layout();

    m_shell.addShellListener(
        new ShellAdapter() {

          @Override
          public void shellClosed(ShellEvent e) {
            System.exit(0);
          }
        });

    while (!m_shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
  /** @param args ; */
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new GridLayout(1, false));

    final Combo combo = new Combo(shell, SWT.READ_ONLY);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

    Button button = new Button(shell, SWT.PUSH);
    button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    button.setText("OK");
    button.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            CustomMatchConditionDialog dialog = new CustomMatchConditionDialog(shell);
            int res = dialog.open();
            if (res == CustomMatchConditionDialog.OK) {}
          }
        });

    shell.open();

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
示例#25
0
 private boolean showDialog() {
   shell.open();
   while (!shell.isDisposed()) {
     if (!shell.getDisplay().readAndDispatch()) shell.getDisplay().sleep();
   }
   return result;
 }
示例#26
0
 public static void main(String[] args) {
   Display display = new Display();
   Shell shell = new Shell(display);
   shell.setLayout(new RowLayout());
   Text text = new Text(shell, SWT.MULTI | SWT.BORDER);
   String modifier = SWT.MOD1 == SWT.CTRL ? "Ctrl" : "Command";
   text.setText("Hit " + modifier + "+Return\nto see\nthe default button\nrun");
   text.addTraverseListener(
       e -> {
         switch (e.detail) {
           case SWT.TRAVERSE_RETURN:
             if ((e.stateMask & SWT.MOD1) != 0) e.doit = true;
         }
       });
   Button button = new Button(shell, SWT.PUSH);
   button.pack();
   button.setText("OK");
   button.addSelectionListener(
       new SelectionAdapter() {
         @Override
         public void widgetSelected(SelectionEvent e) {
           System.out.println("OK selected");
         }
       });
   shell.setDefaultButton(button);
   shell.pack();
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
示例#27
0
  public InputViewer(Shell parent, Properties properties, String resources) {
    sShell = new org.eclipse.swt.widgets.Shell(parent);
    sShell.setLocation(parent.getLocation().x + 200, parent.getLocation().y + 150);
    sShell.setSize(new org.eclipse.swt.graphics.Point(471, 146));
    sShell.setLayout(null);

    listeners = new Vector<DialogInputListener>();

    ApplicationFactory factory = new ApplicationFactory(sShell, resources, getClass().getName());

    factory.createLabel("lbl").setBounds(15, 15, 100, 20);

    txtName = factory.createText();
    txtName.setBounds(120, 15, 280, 20);
    txtName.addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            if (e.keyCode != 13) return;
            enter();
          }
        });
    factory
        .createButton(
            "but",
            new SelectionAdapter() {
              @SuppressWarnings("unused")
              public void widgetSelected(SelectionEvent e) {
                enter();
              }
            })
        .setBounds(180, 50, 90, 20);

    sShell.setSize(420, 120);
    sShell.open();
  }
示例#28
0
  public static void main(String[] args) {
    Display d = new Display();
    Shell shell = new Shell(d);
    shell.setText("GraphSnippet1");
    shell.setLayout(new FillLayout());
    shell.setSize(400, 400);

    final Graph g = new Graph(shell, SWT.NONE);

    hookMenu(g);

    SpaceTreeLayoutAlgorithm spaceTreeLayoutAlgorithm = new SpaceTreeLayoutAlgorithm();
    g.setLayoutAlgorithm(spaceTreeLayoutAlgorithm, false);
    g.setExpandCollapseManager(spaceTreeLayoutAlgorithm.getExpandCollapseManager());

    g.setSubgraphFactory(new DefaultSubgraph.LabelSubgraphFactory());

    for (int i = 0; i < 20; i++) {
      GraphNode graphNode = new GraphNode(g, SWT.NONE);
      graphNode.setText("" + i);
    }

    shell.open();
    while (!shell.isDisposed()) {
      while (!d.readAndDispatch()) {
        d.sleep();
      }
    }
  }
示例#29
0
  private void open() {

    display = Display.getDefault();

    shell = new Shell();

    shell.setSize(250, 170);

    // ---------创建窗口中的其他界面组件-------------

    shell.setLayout(new GridLayout());

    createMainComp(shell); // 创建主面板

    createStatusbar(shell); // 创建工具栏
    // -----------------END------------------------

    shell.layout();

    shell.open();

    while (!shell.isDisposed()) {

      if (!display.readAndDispatch()) display.sleep();
    }

    display.dispose();
  }
示例#30
0
  public long open(long aLimit) {
    limit = aLimit;
    finalResult = -1L;
    buttonPressed = 0;
    if (sShell == null || sShell.isDisposed()) {
      createSShell();
    }

    sShell.pack();
    Manager.reduceDistance(getParent(), sShell);
    if (lastHexButtonSelected) {
      hexRadioButton.setSelection(true);
    } else {
      decRadioButton.setSelection(true);
    }
    label.setText(
        "Enter location number, 0 to " + limit + " (0x0 to 0x" + Long.toHexString(limit) + ")");
    text.setText(lastLocationText);
    text.selectAll();
    text.setFocus();
    sShell.open();
    Display display = getParent().getDisplay();
    while (!sShell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }

    return finalResult;
  }