Пример #1
0
  private void runSession() {
    while (true) {
      shell = arseGUI.open(display);
      initializeARSE();
      while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) display.sleep();
      }

      if (gameMasterMode) {
        gameMasterSession = new GameMasterSession(display);
        gameMasterSession.open();

        gameMasterMode = false;
      } else if (playerMode) {
        playerLoginGUI = new PlayerLoginGUI();
        playerSession = new PlayerSession(display);
        shell = playerLoginGUI.open(display);
        initializePlayerLoginGUI();
        while (!shell.isDisposed()) {
          if (!display.readAndDispatch()) display.sleep();
        }

        if (playerSession.loggedIn()) {
          playerSession.open();
        }
        playerMode = false;
      } else break;
    }
  }
Пример #2
0
  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();
      }
    }
  }
Пример #3
0
  /** ********************* 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) {
    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();
  }
Пример #5
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();
  }
Пример #6
0
  /**
   * Launch the application
   *
   * @param args
   */
  public static void main(String args[]) {
    Display display = Display.getDefault();
    IETest shell = new IETest(display);
    shell.setMaximized(true);
    shell.setLayout(new FillLayout());
    Menu bar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(bar);

    OleFrame frame = new OleFrame(shell, SWT.NONE);
    OleControlSite clientsite = null;
    OleAutomation browser = null;
    try {

      clientsite = new OleControlSite(frame, SWT.NONE, "Shell.Explorer");
      browser = new OleAutomation(clientsite);
      clientsite.doVerb(OLE.OLEIVERB_INPLACEACTIVATE);
      shell.open();
      int[] browserIDs = browser.getIDsOfNames(new String[] {"Navigate", "URL"});
      Variant[] address = new Variant[] {new Variant("http://blog.csdn.net/bovy")};
      browser.invoke(browserIDs[0], address, new int[] {browserIDs[1]});
    } catch (Exception ex) {
      System.out.println("Failed to create IE! " + ex.getMessage());
      return;
    }
    while (shell != null && !shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    browser.dispose();
    display.dispose();
  }
Пример #7
0
  public void add() {
    qprint.verbose("Add pressed. Create File");

    Display display = Display.getDefault();

    QFileManagerShell fm = new QFileManagerShell();
    while (!fm.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    QFileType file = fm.getFile();
    if (null == file) {
      qprint.error("file is null");
      return;
    }

    // create a new file and update tree
    File f = new File(file.getFilePath());
    try {
      qprint.verbose("create file " + f.getName());
      f.createNewFile();
      qtree.update();
    } catch (IOException e) {
      qprint.error("Imposible to create file");
    }
  }
Пример #8
0
 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();
 }
Пример #9
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();
  }
Пример #10
0
  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
 @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);
   }
 }
  /** @param args */
  public static void main(String[] args) throws Exception {
    // TODO Auto-generated method stub
    /* Before this is run, be sure to set up the launch configuration (Arguments->VM Arguments)
     * for the correct SWT library path in order to run with the SWT dlls.
     * The dlls are located in the SWT plugin jar.
     * For example, on Windows the Eclipse SWT 3.1 plugin jar is:
     *       installation_directory\plugins\org.eclipse.swt.win32_3.1.0.jar
     */
    Display display = Display.getDefault();
    ActiveHostsFileWindow thisClass = new ActiveHostsFileWindow();
    thisClass.createSShell();
    thisClass.sShell.open();

    /*
     * Loads active hosts file
     */
    File activeHostsFile = getActiveHostsFile();
    thisClass.highlightActiveHostsFile(activeHostsFile);
    thisClass.label.setText("Current hosts file (located at " + activeHostsFile.getPath() + ")");

    HostsFile hf = thisClass.loadHostsFile(activeHostsFile);

    System.out.println("Lines: " + hf.getHostsFileLines().size());

    HostsFileDAO hfDAO = new HostsFileSerializationDAO();
    hfDAO.save(hf);

    while (!thisClass.sShell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #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 Object run(Object args) throws Exception {
   this.setArguments((String[]) args);
   testableObject = PlatformUI.getTestableObject();
   testableObject.setTestHarness(this);
   Display display = PlatformUI.createDisplay();
   try {
     // delete generated JavaProjects in Eclipse Run Configuration Directory
     String[] cmdArray = new String[3];
     cmdArray[0] = "rm";
     cmdArray[1] = "-rf";
     cmdArray[2] = "/media/jefferson/Expansion Drive/runtime-ferramentaLPS.MainRunner";
     Runtime rt = Runtime.getRuntime();
     Process proc = rt.exec(cmdArray);
     System.out.println("SPL Refactoring Checker");
     PlatformUI.createAndRunWorkbench(display, new NullAdvisor());
     AppWindow refinementChecker = new AppWindow("Software Product Line Refinement Checker");
     refinementChecker.open();
     Shell shell = refinementChecker.getShell();
     while (!shell.isDisposed()) {
       if (!display.readAndDispatch()) display.sleep();
     }
     return EXIT_OK;
   } finally {
     display.dispose();
   }
 }
Пример #16
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();
      }
    }
  }
Пример #17
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);
  }
 static boolean runLoopTimer(final Display display, final Shell shell, final int seconds) {
   final boolean[] timeout = {false};
   new Thread() {
     @Override
     public void run() {
       try {
         for (int i = 0; i < seconds; i++) {
           Thread.sleep(seconds * 1000);
           if (display.isDisposed() || shell.isDisposed()) return;
         }
       } catch (Exception e) {
       }
       timeout[0] = true;
       /* wake up the event loop */
       if (!display.isDisposed()) {
         display.asyncExec(
             () -> {
               if (!shell.isDisposed()) shell.redraw();
             });
       }
     }
   }.start();
   while (!timeout[0] && !shell.isDisposed()) if (!display.readAndDispatch()) display.sleep();
   return timeout[0];
 }
 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();
 }
  /** @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();
  }
Пример #21
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();
 }
Пример #22
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();
      }
    }
  }
Пример #23
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();
  }
Пример #24
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();
  }
Пример #25
0
  /** 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();
    }
  }
  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();
  }
Пример #27
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();
  }
  /** @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();
      }
    }
  }
Пример #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 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();
 }