@Override
  public void processContents(MElementContainer<MUIElement> element) {
    if (!(((MUIElement) element) instanceof MWindow)) {
      return;
    }
    MWindow mWindow = (MWindow) ((MUIElement) element);
    Shell shell = (Shell) element.getWidget();

    // Populate the main menu
    IPresentationEngine2 renderer =
        (IPresentationEngine2) context.get(IPresentationEngine.class.getName());
    if (mWindow.getMainMenu() != null) {
      renderer.createGui(mWindow.getMainMenu(), element);
      shell.setMenuBar((Menu) mWindow.getMainMenu().getWidget());
    }

    // create Detached Windows
    for (MWindow dw : mWindow.getWindows()) {
      renderer.createGui(dw, element);
    }

    // Populate the trim (if any)
    if (mWindow instanceof MTrimmedWindow) {
      MTrimmedWindow tWindow = (MTrimmedWindow) mWindow;
      for (MTrimBar trimBar : tWindow.getTrimBars()) {
        renderer.createGui(trimBar, element);
      }
    }

    shell.pack();
    shell.open();
  }
Exemple #2
0
 void createMenuBar() {
   org.eclipse.swt.widgets.Menu bar = new org.eclipse.swt.widgets.Menu(shell, SWT.BAR);
   shell.setMenuBar(bar);
   org.eclipse.swt.widgets.MenuItem fileItem =
       new org.eclipse.swt.widgets.MenuItem(bar, SWT.CASCADE);
   fileItem.setText(resources.getString("File_menuitem"));
   fileItem.setMenu(createFileMenu());
 }
  /**
   * Creates the menu at the top of the shell where most of the programs functionality is accessed.
   *
   * @return The <code>Menu</code> widget that was created
   */
  private Menu createMenuBar() {
    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);

    // create each header and subMenu for the menuBar
    createFileMenu(menuBar);
    createEditMenu(menuBar);
    createSearchMenu(menuBar);
    createHelpMenu(menuBar);

    return menuBar;
  }
  /**
   * Create contents of the window.
   *
   * @wbp.parser.entryPoint
   */
  protected void createContents() {
    shell = new Shell();
    shell.setSize(450, 300);
    shell.setText("buy train ticket");
    shell.setLayout(new FormLayout());

    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);

    MenuItem actionMenuItem = new MenuItem(menuBar, SWT.CASCADE);
    actionMenuItem.setText("Action");

    Menu actionMenu = new Menu(actionMenuItem);
    actionMenuItem.setMenu(actionMenu);

    MenuItem buyTrainTicketMenuItem = new MenuItem(actionMenu, SWT.NONE);
    buyTrainTicketMenuItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            BuyTrainTicketDialog dialog = new BuyTrainTicketDialog(shell);
            dialog.open();
          }
        });
    buyTrainTicketMenuItem.setText("Buy Train Ticket");

    MenuItem viewMenuItem = new MenuItem(menuBar, SWT.CASCADE);
    viewMenuItem.setText("View");

    Menu viewMenu = new Menu(viewMenuItem);
    viewMenuItem.setMenu(viewMenu);

    MenuItem messagesMenuItem = new MenuItem(viewMenu, SWT.NONE);
    messagesMenuItem.setText("Messages");

    int browserStyle = SWT.NONE;
    if (System.getProperty("os.name").equals("Linux")) {
      browserStyle = SWT.MOZILLA;
    }
    browser = new Browser(shell, browserStyle);
    FormData fd_browser = new FormData();
    fd_browser.bottom = new FormAttachment(0, 247);
    fd_browser.right = new FormAttachment(0, 442);
    fd_browser.top = new FormAttachment(0);
    fd_browser.left = new FormAttachment(0);
    browser.setLayoutData(fd_browser);

    this.shell.setMaximized(true);
  }
Exemple #5
0
  /**
   * Create the menu.
   *
   * @param shell the container shell
   * @param simGUI the simulation's GUI
   * @param siafuConfig the config for Siafu
   */
  public MainMenu(final Shell shell, final GUI simGUI, final XMLConfiguration siafuConfig) {
    this.shell = shell;
    this.gui = simGUI;
    this.siafuConfig = siafuConfig;
    menuBar = new Menu(shell, SWT.BAR);

    simulationMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
    simulationMenuHeader.setText("&Simulation");
    createSimulationMenu(simulationMenuHeader);

    optionsMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
    optionsMenuHeader.setText("Op&tions");
    createOptionsMenu(optionsMenuHeader);

    helpMenuHeader = new MenuItem(menuBar, SWT.CASCADE);
    helpMenuHeader.setText("&Help");
    createHelpMenu(helpMenuHeader);

    shell.setMenuBar(menuBar);
  }
Exemple #6
0
  /** Create the GUI */
  protected void createGui() {
    setLayout(new FillLayout());

    // recognize the app is ending and confirm
    shell.addShellListener(
        new ShellAdapter() {
          public void shellClosed(ShellEvent e) {
            MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
            mb.setText("Confirm Exit");
            mb.setMessage("Are you sure you want to exit?");
            int rc = mb.open();
            e.doit = rc == SWT.OK;
          }
        });

    // Layout the (dummy) contents
    Label body = new Label(this, SWT.CENTER);
    body.setText("Sample body");

    // Create the menu system
    Menu main = createMenu(shell, SWT.BAR | SWT.LEFT_TO_RIGHT);
    shell.setMenuBar(main);

    MenuItem fileMenuItem = createMenuItem(main, SWT.CASCADE, "&File", null, -1, true, null);
    Menu fileMenu = createMenu(shell, SWT.DROP_DOWN, fileMenuItem, true);
    MenuItem exitMenuItem =
        createMenuItem(fileMenu, SWT.PUSH, "E&xit\tCtrl+X", null, SWT.CTRL + 'X', true, "doExit");

    MenuItem helpMenuItem = createMenuItem(main, SWT.CASCADE, "&Help", null, -1, true, null);
    Menu helpMenu = createMenu(shell, SWT.DROP_DOWN, helpMenuItem, true);
    MenuItem aboutMenuItem =
        createMenuItem(helpMenu, SWT.PUSH, "&About\tCtrl+A", null, SWT.CTRL + 'A', true, "doAbout");

    // add popup menu
    Menu popup = createPopupMenu(shell, body);
    MenuItem popupMenuItem1 = createMenuItem(popup, SWT.PUSH, "&About", null, -1, true, "doAbout");
    MenuItem popupMenuItem2 = createMenuItem(popup, SWT.PUSH, "&Noop", null, -1, true, "doNothing");
  }
 public static void main(String[] args) {
   Display display = new Display();
   final Shell shell = new Shell(display);
   shell.setText("Text Editor");
   Menu bar = new Menu(shell, SWT.BAR);
   shell.setMenuBar(bar);
   MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
   fileItem.setText("&File");
   Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
   fileItem.setMenu(fileMenu);
   MenuItem saveItem = new MenuItem(fileMenu, SWT.PUSH);
   saveItem.setText("&Save\tCtrl+S");
   saveItem.setAccelerator(SWT.MOD1 + 'S');
   saveItem.addListener(SWT.Selection, e -> shell.setModified(false));
   MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
   exitItem.setText("Exit");
   exitItem.addListener(SWT.Selection, e -> shell.close());
   Text text = new Text(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
   text.addListener(SWT.Modify, e -> shell.setModified(true));
   shell.addListener(
       SWT.Close,
       e -> {
         if (shell.getModified()) {
           MessageBox box = new MessageBox(shell, SWT.PRIMARY_MODAL | SWT.OK | SWT.CANCEL);
           box.setText(shell.getText());
           box.setMessage("You have unsaved changes, do you want to exit?");
           e.doit = box.open() == SWT.OK;
         }
       });
   shell.setLayout(new FillLayout());
   shell.open();
   while (!shell.isDisposed()) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
  /** Create contents of the window. */
  protected void createContents() {
    shlMcScheduler = new Shell();
    shlMcScheduler.setSize(803, 401);
    shlMcScheduler.setText("MC3 Scheduler");

    // MENU BAR
    Menu MenuBar = new Menu(shlMcScheduler, SWT.BAR);
    shlMcScheduler.setMenuBar(MenuBar);

    // FILE
    MenuItem FileMenu = new MenuItem(MenuBar, SWT.CASCADE);
    FileMenu.setText("File");

    Menu FileCascade = new Menu(FileMenu);
    FileMenu.setMenu(FileCascade);

    MenuItem mntmSave = new MenuItem(FileCascade, SWT.NONE);
    mntmSave.setText("Save");

    MenuItem mntmOpen = new MenuItem(FileCascade, SWT.NONE);
    mntmOpen.setText("Open");

    MenuItem mntmExit = new MenuItem(FileCascade, SWT.NONE);
    mntmExit.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shlMcScheduler.close();
          }
        });
    mntmExit.setText("Exit");

    // EDIT
    MenuItem EditMenu = new MenuItem(MenuBar, SWT.CASCADE);
    EditMenu.setText("Edit");

    Menu EditCascade = new Menu(EditMenu);
    EditMenu.setMenu(EditCascade);

    // INSERT
    MenuItem InsertMenu = new MenuItem(MenuBar, SWT.CASCADE);
    InsertMenu.setText("Insert");

    Menu InsertCascade = new Menu(InsertMenu);
    InsertMenu.setMenu(InsertCascade);

    MenuItem InsertTranscript = new MenuItem(InsertCascade, SWT.NONE);
    InsertTranscript.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            final InsertDialog dial = new InsertDialog(shlMcScheduler, 1, txtXscript);
            dial.open();
          }
        });
    InsertTranscript.setText("Insert Transcript");

    MenuItem InsertCoursePlan = new MenuItem(InsertCascade, SWT.NONE);
    InsertCoursePlan.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            final InsertDialog dial = new InsertDialog(shlMcScheduler, 1, txtCoursePlan);
            dial.open();
          }
        });
    InsertCoursePlan.setText("Insert Course Plan");

    MenuItem InsertCourseList = new MenuItem(InsertCascade, SWT.NONE);
    InsertCourseList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {}
        });
    InsertCourseList.setText("Insert a Course List");

    // WINDOW TABS
    TabFolder WindowTab = new TabFolder(shlMcScheduler, SWT.NONE);
    WindowTab.setBounds(0, 0, 565, 343);

    // TRANSCRIPT TAB
    TabItem TranscriptTab = new TabItem(WindowTab, SWT.NONE);
    TranscriptTab.setText("Transcript");

    Composite TranscriptWindow = new Composite(WindowTab, SWT.NONE);
    TranscriptTab.setControl(TranscriptWindow);

    txtXscript =
        new Text(
            TranscriptWindow,
            SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
    txtXscript.setEditable(false);
    txtXscript.setText("Insert your Transcript!");
    txtXscript.setBounds(0, 0, 557, 315);

    // COURSE PLAN TAB
    TabItem CoursePlanTab = new TabItem(WindowTab, SWT.NONE);
    CoursePlanTab.setText("Course Plan");

    Composite CoursePlanWindow = new Composite(WindowTab, SWT.NONE);
    CoursePlanTab.setControl(CoursePlanWindow);

    txtCoursePlan =
        new Text(
            CoursePlanWindow,
            SWT.BORDER | SWT.READ_ONLY | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
    txtCoursePlan.setText("Insert your Course Plan");
    txtCoursePlan.setEditable(false);
    txtCoursePlan.setBounds(0, 0, 557, 315);

    // COURSE LIST TAB
    TabItem CourseListTab = new TabItem(WindowTab, SWT.NONE);
    CourseListTab.setText("Course List");

    Composite CourseListWindow = new Composite(WindowTab, SWT.NONE);
    CourseListTab.setControl(CourseListWindow);

    final List cList = new List(CourseListWindow, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    cList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            currentCourseSelected = cList.getSelection()[0];
          }
        });
    cList.setBounds(0, 0, 557, 315);
    cList.add("MATH TEST");
    cList.add("SCIENCE TEST");

    TabItem CalendarTab = new TabItem(WindowTab, SWT.NONE);
    CalendarTab.setText("Calendar");

    Composite CalenderWindow = new Composite(WindowTab, SWT.NONE);
    CalenderWindow.setEnabled(false);
    CalendarTab.setControl(CalenderWindow);

    table = new Table(CalenderWindow, SWT.BORDER | SWT.FULL_SELECTION);
    table.setBounds(0, 0, 557, 315);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);

    TableColumn SunColumn = new TableColumn(table, SWT.NONE);
    SunColumn.setWidth(79);
    SunColumn.setText("Sunday");

    TableColumn MonColumn = new TableColumn(table, SWT.NONE);
    MonColumn.setWidth(79);
    MonColumn.setText("Monday");

    TableColumn TueColumn = new TableColumn(table, SWT.NONE);
    TueColumn.setWidth(79);
    TueColumn.setText("Tuesday");

    TableColumn WedsColumn = new TableColumn(table, SWT.NONE);
    WedsColumn.setWidth(79);
    WedsColumn.setText("Wednesday");

    TableColumn ThuColumn = new TableColumn(table, SWT.NONE);
    ThuColumn.setWidth(79);
    ThuColumn.setText("Thursday");

    TableColumn FriColumn = new TableColumn(table, SWT.NONE);
    FriColumn.setWidth(79);
    FriColumn.setText("Friday");

    TableColumn SatColumn = new TableColumn(table, SWT.NONE);
    SatColumn.setWidth(79);
    SatColumn.setText("Saturday");

    //
    Label LabelSelectedCourses = new Label(shlMcScheduler, SWT.NONE);
    LabelSelectedCourses.setLocation(621, 2);
    LabelSelectedCourses.setSize(112, 15);
    LabelSelectedCourses.setText("Selected Courses");

    Composite SelectedCoursesWindow = new Composite(shlMcScheduler, SWT.NONE);
    SelectedCoursesWindow.setBounds(571, 23, 206, 310);

    final List selectedList = new List(SelectedCoursesWindow, SWT.BORDER);
    selectedList.setBounds(0, 0, 206, 269);
    selectedList.add("No Courses Selected");

    Button btnRemoveCourse = new Button(SelectedCoursesWindow, SWT.NONE);
    btnRemoveCourse.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              removeCurrentCourse(selectedList, selectedList.getSelection()[0]);
            } catch (ArrayIndexOutOfBoundsException error) {
              final ErrorDialog err = new ErrorDialog(shlMcScheduler, 1);
              err.open();
            }
          }
        });
    btnRemoveCourse.setBounds(111, 275, 95, 25);
    btnRemoveCourse.setText("Remove Course");

    Button btnAddCourse = new Button(SelectedCoursesWindow, SWT.NONE);
    btnAddCourse.setBounds(0, 275, 95, 25);
    btnAddCourse.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseUp(MouseEvent e) {
            try {
              addCurrentCourse(selectedList, cList.getSelection()[0]);
            } catch (ArrayIndexOutOfBoundsException error) {
              final ErrorDialog err = new ErrorDialog(shlMcScheduler, 1);
              err.open();
            }
          }
        });
    btnAddCourse.setText("Add Course");
  }
Exemple #9
0
  public static void main(final String[] args) {
    System.setProperty("ardor3d.useMultipleContexts", "true");

    final Timer timer = new Timer();
    final FrameHandler frameWork = new FrameHandler(timer);
    final LogicalLayer logicalLayer = new LogicalLayer();

    final MyExit exit = new MyExit();
    final ExampleScene scene = new ExampleScene();
    final RotatingCubeGame game = new RotatingCubeGame(scene, exit, logicalLayer, Key.T);

    frameWork.addUpdater(game);

    // INIT SWT STUFF
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    // This is our tab folder, it will be accepting our 3d canvases
    final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);

    // Add a menu item that will create and add a new canvas.
    final Menu bar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(bar);

    final MenuItem fileItem = new MenuItem(bar, SWT.CASCADE);
    fileItem.setText("&Tasks");

    final Menu submenu = new Menu(shell, SWT.DROP_DOWN);
    fileItem.setMenu(submenu);
    final MenuItem item = new MenuItem(submenu, SWT.PUSH);
    item.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(final Event e) {
            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        addNewCanvas(tabFolder, scene, frameWork, logicalLayer);
                      }
                    });
          }
        });
    item.setText("Add &3d Canvas");
    item.setAccelerator(SWT.MOD1 + '3');

    AWTImageLoader.registerLoader();

    try {
      final SimpleResourceLocator srl =
          new SimpleResourceLocator(
              ResourceLocatorTool.getClassPathResource(
                  LwjglSwtExample.class, "com/ardor3d/example/media/"));
      ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, srl);
    } catch (final URISyntaxException ex) {
      ex.printStackTrace();
    }

    addNewCanvas(tabFolder, scene, frameWork, logicalLayer);

    shell.open();

    game.init();
    // frameWork.init();

    while (!shell.isDisposed() && !exit.isExit()) {
      display.readAndDispatch();
      frameWork.updateFrame();
      Thread.yield();

      // using the below way makes things really jerky. Not sure how to handle that.

      // if (display.readAndDispatch()) {
      // frameWork.updateFrame();
      // }
      // else {
      // display.sleep();
      // }
    }

    display.dispose();
    System.exit(0);
  }
Exemple #10
0
  /** Initialize the drop-down menus in the appropriate area of the window */
  public void initMenu() {
    Menu menuBar = new Menu(shell, SWT.BAR);
    MenuItem cascadeFileMenu = new MenuItem(menuBar, SWT.CASCADE);
    cascadeFileMenu.setText("&File");
    MenuItem cascadeAnimMenu = new MenuItem(menuBar, SWT.CASCADE);
    cascadeAnimMenu.setText("&Animation");

    // file menu
    Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
    cascadeFileMenu.setMenu(fileMenu);

    MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
    exitItem.setText("&Exit");

    MenuItem openGraphItem = new MenuItem(fileMenu, SWT.PUSH);
    openGraphItem.setText("Open &Graph");

    MenuItem openAnimationItem = new MenuItem(fileMenu, SWT.PUSH);
    openAnimationItem.setText("Open &Animation");

    // temporary animation menu
    Menu animMenu = new Menu(shell, SWT.DROP_DOWN);
    cascadeAnimMenu.setMenu(animMenu);

    MenuItem DFSItem = new MenuItem(animMenu, SWT.PUSH);
    DFSItem.setText("Depth First Search");

    // add the menubar to the shell
    shell.setMenuBar(menuBar);

    // actions for the menu items

    exitItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shell.getDisplay().dispose();
            System.exit(0);
          }
        });

    openGraphItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.NULL);
            String path = dialog.open();
            controller.LoadGraph(path);
          }
        });

    openAnimationItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.NULL);
            String path = dialog.open();
            controller.LoadAnimation(path);
          }
        });

    DFSItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            controller.LoadDFSAnimation();
          }
        });
  }
Exemple #11
0
  private void initMenus() {

    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);

    // Jeu

    {
      MenuItem itemFile = new MenuItem(menuBar, SWT.CASCADE);
      itemFile.setText("&Jeu");

      Menu menuFile = new Menu(shell, SWT.DROP_DOWN);
      itemFile.setMenu(menuFile);

      {
        itemConnectAndJoin = new MenuItem(menuFile, SWT.PUSH);
        itemConnectAndJoin.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clickConnectAndJoin();
              }
            });
        itemConnectAndJoin.setText("Re&joindre une partie...\tCtrl+J");

        itemConnectAndJoin.setAccelerator(SWT.CTRL + 'J');
      }

      {
        itemCreateJoinAndPlay = new MenuItem(menuFile, SWT.PUSH);
        itemCreateJoinAndPlay.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clickCreateJoinAndPlay();
              }
            });
        itemCreateJoinAndPlay.setText("&Créer une partie et jouer...\tCtrl+N");

        itemCreateJoinAndPlay.setAccelerator(SWT.CTRL + 'N');
      }

      {
        itemCreateJoin = new MenuItem(menuFile, SWT.PUSH);
        itemCreateJoin.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clickCreateAndJoin();
              }
            });
        itemCreateJoin.setText("&Créer une partie et l'observer");
      }

      new MenuItem(menuFile, SWT.SEPARATOR);
      {
        MenuItem itemClient = new MenuItem(menuFile, SWT.CASCADE);
        itemClient.setText("&Client...");

        Menu menuClient = new Menu(shell, SWT.DROP_DOWN);
        itemClient.setMenu(menuClient);

        {
          itemObserve = new MenuItem(menuClient, SWT.PUSH);
          itemObserve.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickConnect();
                }
              });
          itemObserve.setText("Observer...");
        }

        {
          itemJoin = new MenuItem(menuClient, SWT.PUSH);
          itemJoin.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickJoin();
                }
              });
          itemJoin.setText("Participer...");
        }

        {
          itemDisconnect = new MenuItem(menuClient, SWT.PUSH);
          itemDisconnect.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickDisconnect();
                }
              });
          itemDisconnect.setText("&Déconnecter...\tCtrl+D");
          itemDisconnect.setAccelerator(SWT.CTRL + 'D');
        }
      }

      new MenuItem(menuFile, SWT.SEPARATOR);

      {
        MenuItem itemServer = new MenuItem(menuFile, SWT.CASCADE);
        itemServer.setText("&Serveur...");

        Menu menuServer = new Menu(shell, SWT.DROP_DOWN);
        itemServer.setMenu(menuServer);

        {
          itemCreateServerLocal = new MenuItem(menuServer, SWT.PUSH);
          itemCreateServerLocal.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickCreateServerLocal();
                }
              });
          itemCreateServerLocal.setText("Créer un serveur &local");
        }

        {
          itemCreateServer = new MenuItem(menuServer, SWT.PUSH);
          itemCreateServer.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickCreateServer();
                }
              });
          itemCreateServer.setText("Créer un serveur...");
        }
        {
          itemShutdownServer = new MenuItem(menuServer, SWT.PUSH);
          itemShutdownServer.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickShutdownServer();
                }
              });
          itemShutdownServer.setText("Eteindre le serveur");
        }
        {
          itemCreateGame = new MenuItem(menuServer, SWT.PUSH);
          itemCreateGame.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event e) {
                  clickCreateGame();
                }
              });
          itemCreateGame.setText("&Créer une partie...\tCtrl+C");
          itemCreateGame.setAccelerator(SWT.CTRL + 'C');
        }
      }

      new MenuItem(menuFile, SWT.SEPARATOR);

      {
        MenuItem itemQuit = new MenuItem(menuFile, SWT.PUSH);
        itemQuit.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clickQuit();
              }
            });
        itemQuit.setText("&Quitter...\tCtrl+Q");
        itemQuit.setAccelerator(SWT.CTRL + 'Q');
      }
      // item.setAccelerator (SWT.MOD1 + 'A');
    }

    {
      MenuItem itemView = new MenuItem(menuBar, SWT.CASCADE);
      itemView.setText("&Vue");

      Menu menuView = new Menu(shell, SWT.DROP_DOWN);
      itemView.setMenu(menuView);

      {
        MenuItem itemZoomIn = new MenuItem(menuView, SWT.PUSH);
        itemZoomIn.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clientWhiteboard.zoomIn();
              }
            });
        itemZoomIn.setText("Zoom &in\tCtrl+'+'");
        itemZoomIn.setAccelerator(SWT.CTRL + '+');
      }

      {
        MenuItem itemZoomOut = new MenuItem(menuView, SWT.PUSH);
        itemZoomOut.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clientWhiteboard.zoomOut();
              }
            });
        itemZoomOut.setText("Zoom &out\tCtrl+'-'");
        itemZoomOut.setAccelerator(SWT.CTRL + '-');
      }

      {
        MenuItem itemZoomReset = new MenuItem(menuView, SWT.PUSH);
        itemZoomReset.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clientWhiteboard.zoomOne();
              }
            });
        itemZoomReset.setText("Zoom &1:1\tCtrl+0");
        itemZoomReset.setAccelerator(SWT.CTRL + '0');
      }

      {
        MenuItem itemZoomToFit = new MenuItem(menuView, SWT.PUSH);
        itemZoomToFit.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clientWhiteboard.fitToScreen();
              }
            });
        itemZoomToFit.setText("Zoom to &fit...\tCtrl+F");
        itemZoomToFit.setAccelerator(SWT.CTRL + 'F');
      }

      new MenuItem(menuView, SWT.SEPARATOR);

      {
        MenuItem itemShowRoot = new MenuItem(menuView, SWT.PUSH);
        itemShowRoot.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clientWhiteboard.centerOnRootIdea();
              }
            });
        itemShowRoot.setText("Voir idée &racine\tCtrl+R");
        itemShowRoot.setAccelerator(SWT.CTRL + 'R');
      }

      new MenuItem(menuView, SWT.SEPARATOR);

      {
        MenuItem itemParams = new MenuItem(menuView, SWT.PUSH);
        itemParams.addListener(
            SWT.Selection,
            new Listener() {
              public void handleEvent(Event e) {
                clickEditVisuParams();
              }
            });
        itemParams.setText("&Parameters");
      }
    }
  }
  public static void main(String[] args) {
    Shell shell = new Shell();
    Display display = shell.getDisplay();
    shell.setLayout(new FillLayout());
    shell.setText("ExpandBar Example");

    Menu menubar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menubar);
    MenuItem fileItem = new MenuItem(menubar, SWT.CASCADE);
    fileItem.setText("&File");
    Menu submenu = new Menu(shell, SWT.DROP_DOWN);
    fileItem.setMenu(submenu);
    item = new MenuItem(submenu, SWT.PUSH);
    item.setText("New ExpandItem");

    bar = new ExpandBar(shell, SWT.V_SCROLL);
    image = display.getSystemImage(SWT.ICON_QUESTION);

    // First item
    Composite composite = new Composite(bar, SWT.NONE);
    Menu popupmenu = new Menu(shell, SWT.POP_UP);
    MenuItem popupItem = new MenuItem(popupmenu, SWT.PUSH);
    popupItem.setText("Popup");
    composite.setMenu(popupmenu);

    GridLayout layout = new GridLayout(2, false);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
    layout.verticalSpacing = 10;
    composite.setLayout(layout);
    Label label = new Label(composite, SWT.NONE);
    label.setImage(display.getSystemImage(SWT.ICON_ERROR));
    label = new Label(composite, SWT.NONE);
    label.setText("SWT.ICON_ERROR");
    label = new Label(composite, SWT.NONE);
    label.setImage(display.getSystemImage(SWT.ICON_INFORMATION));
    label = new Label(composite, SWT.NONE);
    label.setText("SWT.ICON_INFORMATION");
    label = new Label(composite, SWT.NONE);
    label.setImage(display.getSystemImage(SWT.ICON_WARNING));
    label = new Label(composite, SWT.NONE);
    label.setText("SWT.ICON_WARNING");
    label = new Label(composite, SWT.NONE);
    label.setImage(display.getSystemImage(SWT.ICON_QUESTION));
    label = new Label(composite, SWT.NONE);
    label.setText("SWT.ICON_QUESTION");
    ExpandItem item1 = new ExpandItem(bar, SWT.NONE);
    item1.setText("What is your favorite icon");
    item1.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
    item1.setControl(composite);
    item1.setImage(image);

    // Second item
    composite = new Composite(bar, SWT.NONE);
    layout = new GridLayout(2, true);
    layout.marginLeft = layout.marginTop = layout.marginRight = layout.marginBottom = 10;
    layout.verticalSpacing = 10;
    composite.setLayout(layout);
    Button button1 = new Button(composite, SWT.PUSH);
    button1.setText("Button 1");
    Button button2 = new Button(composite, SWT.PUSH);
    button2.setText("Button 2");

    ExpandItem item0 = new ExpandItem(bar, SWT.NONE);
    item0.setText("What is your favorite button");
    item0.setHeight(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
    item0.setControl(composite);
    item0.setImage(image);
    item0.setExpanded(false);

    item.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            ExpandItem item2 = new ExpandItem(bar, SWT.NONE);
            Composite composite = new Composite(bar, SWT.NONE);
            GridLayout layout = new GridLayout(2, false);
            composite.setLayout(layout);
            Label label = new Label(composite, SWT.NONE);
            label.setText("What is your name?");
            Composite pcomposite = new Composite(composite, SWT.NONE);
            Text text = new Text(pcomposite, SWT.NONE);
            item2.setText("New Question");
            text.pack();
            composite.pack();
            Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            item2.setHeight(size.y);
            item2.setControl(composite);
            item2.setImage(image);
            item2.setExpanded(true);
          }
        });

    bar.setSpacing(8);
    shell.setSize(400, 550);
    shell.open();
    System.out.println("------------------------------");
    System.out.println("getSize: " + button1.getSize());
    System.out.println("getBounds: " + button1.getBounds());
    System.out.println("computeSize: " + button1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    System.out.println("getLocation: " + button1.getLocation());

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    image.dispose();
    display.dispose();
  }
Exemple #13
0
  /** Create contents of the window. */
  protected void createContents() {
    shlRigers = new Shell();
    shlRigers.setSize(649, 316);
    shlRigers.setText("RIGERS");
    shlRigers.setLayout(new FormLayout());

    Composite composite = new Composite(shlRigers, SWT.NONE);
    composite.setLayout(new FillLayout(SWT.HORIZONTAL));
    FormData fd_composite = new FormData();
    fd_composite.left = new FormAttachment(0);
    fd_composite.top = new FormAttachment(0);
    fd_composite.bottom = new FormAttachment(0, 276);
    fd_composite.right = new FormAttachment(0, 643);
    composite.setLayoutData(fd_composite);

    TabFolder tabFolder = new TabFolder(composite, SWT.NONE);

    TabItem tbtmViewData = new TabItem(tabFolder, SWT.NONE);
    tbtmViewData.setToolTipText("");
    tbtmViewData.setText("InsertData");

    Composite composite_1 = new Composite(tabFolder, SWT.NONE);
    tbtmViewData.setControl(composite_1);
    composite_1.setLayout(new FillLayout(SWT.VERTICAL));

    Group grpCompartimento = new Group(composite_1, SWT.NONE);
    grpCompartimento.setText("Compartimento");
    grpCompartimento.setLayout(new GridLayout(7, false));

    Label lblId = new Label(grpCompartimento, SWT.NONE);
    lblId.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
    lblId.setText("ID");

    Spinner spinner = new Spinner(grpCompartimento, SWT.BORDER);
    GridData gd_spinner = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_spinner.widthHint = 20;
    spinner.setLayoutData(gd_spinner);
    new Label(grpCompartimento, SWT.NONE);

    Label lblNome = new Label(grpCompartimento, SWT.NONE);
    lblNome.setText("Nome");

    txtAsd = new Text(grpCompartimento, SWT.BORDER);
    GridData gd_txtAsd = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_txtAsd.widthHint = 150;
    txtAsd.setLayoutData(gd_txtAsd);

    Label lblNewLabel = new Label(grpCompartimento, SWT.NONE);
    lblNewLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN));
    lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    lblNewLabel.setText("OK");

    Button btnInsert = new Button(grpCompartimento, SWT.NONE);
    btnInsert.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    btnInsert.setAlignment(SWT.LEFT);
    btnInsert.setText("INSERT");

    Group grpEdificio = new Group(composite_1, SWT.NONE);
    grpEdificio.setText("Edificio");
    grpEdificio.setLayout(new GridLayout(8, false));

    Label lblId_1 = new Label(grpEdificio, SWT.NONE);
    lblId_1.setText("ID");

    Spinner spinner_1 = new Spinner(grpEdificio, SWT.BORDER);
    GridData gd_spinner_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
    gd_spinner_1.widthHint = 20;
    gd_spinner_1.minimumWidth = 20;
    spinner_1.setLayoutData(gd_spinner_1);
    spinner_1.setBounds(0, 0, 440, 79);

    Label lblCompartimento = new Label(grpEdificio, SWT.NONE);
    lblCompartimento.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblCompartimento.setText("Compartimento");

    Combo combo = new Combo(grpEdificio, SWT.NONE);
    combo.setItems(new String[] {"Comp1", "Comp2", "Comp3"});
    GridData gd_combo = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_combo.widthHint = 100;
    combo.setLayoutData(gd_combo);

    Label lblIndirizzo = new Label(grpEdificio, SWT.NONE);
    lblIndirizzo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    lblIndirizzo.setText("Indirizzo");

    text = new Text(grpEdificio, SWT.BORDER);
    GridData gd_text = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gd_text.widthHint = 200;
    text.setLayoutData(gd_text);

    Label lblOk = new Label(grpEdificio, SWT.NONE);
    lblOk.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_GREEN));
    lblOk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1));
    lblOk.setText("OK");

    Button btnInsert_1 = new Button(grpEdificio, SWT.NONE);
    btnInsert_1.setText("INSERT");
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);
    new Label(grpEdificio, SWT.NONE);

    TabItem tbtmInsertData = new TabItem(tabFolder, SWT.NONE);
    tbtmInsertData.setText("View Data");

    Menu menu_1 = new Menu(shlRigers, SWT.BAR);
    shlRigers.setMenuBar(menu_1);

    MenuItem mntmNewSubmenu = new MenuItem(menu_1, SWT.CASCADE);
    mntmNewSubmenu.setText("File");

    Menu menu_2 = new Menu(mntmNewSubmenu);
    mntmNewSubmenu.setMenu(menu_2);

    MenuItem mntmNewItem_1 = new MenuItem(menu_2, SWT.NONE);
    mntmNewItem_1.setText("Connect...");

    new MenuItem(menu_2, SWT.SEPARATOR);

    MenuItem mntmNewItem_2 = new MenuItem(menu_2, SWT.NONE);
    mntmNewItem_2.setText("Quit");
  }
  /** This method initializes sShell */
  private void createSShell() {
    sShell = new Shell();
    sShell.setText("Hosts Juggler");
    sShell.setLayout(null);
    sShell.setSize(new Point(726, 766));

    /*
     * Menu
     */
    final Menu m = new Menu(sShell, SWT.BAR);
    sShell.setMenuBar(m);

    /* Hosts File */
    // create a file menu and add an exit item
    final MenuItem file = new MenuItem(m, SWT.CASCADE);
    file.setText("&Hosts File");
    final Menu filemenu = new Menu(sShell, SWT.DROP_DOWN);
    file.setMenu(filemenu);
    final MenuItem openItem = new MenuItem(filemenu, SWT.CASCADE);
    openItem.setText("&Open");
    final Menu submenu = new Menu(sShell, SWT.DROP_DOWN);
    openItem.setMenu(submenu);
    final MenuItem childItem = new MenuItem(submenu, SWT.PUSH);
    childItem.setText("&Child\tCTRL+C");
    childItem.setAccelerator(SWT.CTRL + 'C');
    final MenuItem dialogItem = new MenuItem(submenu, SWT.PUSH);
    dialogItem.setText("&Dialog\tCTRL+D");
    dialogItem.setAccelerator(SWT.CTRL + 'D');
    final MenuItem separator = new MenuItem(filemenu, SWT.SEPARATOR);
    final MenuItem exitItem = new MenuItem(filemenu, SWT.PUSH);
    exitItem.setText("E&xit");

    // create an edit menu and add cut copy and paste items
    final MenuItem edit = new MenuItem(m, SWT.CASCADE);
    edit.setText("&Edit");
    final Menu editmenu = new Menu(sShell, SWT.DROP_DOWN);
    edit.setMenu(editmenu);
    final MenuItem cutItem = new MenuItem(editmenu, SWT.PUSH);
    cutItem.setText("&Cut");
    final MenuItem copyItem = new MenuItem(editmenu, SWT.PUSH);
    copyItem.setText("Co&py");
    final MenuItem pasteItem = new MenuItem(editmenu, SWT.PUSH);
    pasteItem.setText("&Paste");

    // create an options menu and add menu items
    final MenuItem options = new MenuItem(m, SWT.CASCADE);
    options.setText("&Options");
    final Menu optionsmenu = new Menu(sShell, SWT.DROP_DOWN);
    options.setMenu(optionsmenu);
    final MenuItem checkItem = new MenuItem(optionsmenu, SWT.CHECK);
    checkItem.setText("&Checked Option");
    final MenuItem optionsseparator = new MenuItem(optionsmenu, SWT.SEPARATOR);
    final MenuItem radioItem1 = new MenuItem(optionsmenu, SWT.RADIO);
    radioItem1.setText("Radio &One");
    final MenuItem radioItem2 = new MenuItem(optionsmenu, SWT.RADIO);
    radioItem2.setText("Radio &Two");

    // create a Window menu and add Child item
    final MenuItem window = new MenuItem(m, SWT.CASCADE);
    window.setText("&Window");
    final Menu windowmenu = new Menu(sShell, SWT.DROP_DOWN);
    window.setMenu(windowmenu);
    final MenuItem maxItem = new MenuItem(windowmenu, SWT.PUSH);
    maxItem.setText("Ma&ximize");
    final MenuItem minItem = new MenuItem(windowmenu, SWT.PUSH);
    minItem.setText("Mi&nimize");

    // create a Help menu and add an about item
    final MenuItem help = new MenuItem(m, SWT.CASCADE);
    help.setText("&Help");
    final Menu helpmenu = new Menu(sShell, SWT.DROP_DOWN);
    help.setMenu(helpmenu);
    final MenuItem aboutItem = new MenuItem(helpmenu, SWT.PUSH);
    aboutItem.setText("&About");

    //		/* File */
    //		MenuItem fileItem = new MenuItem (menuBar, SWT.CASCADE);
    //		fileItem.setText("&Hosts File");
    //
    //		Menu submenu = new Menu(sShell, SWT.DROP_DOWN);
    //		fileItem.setMenu(submenu);
    //		MenuItem menuItem = new MenuItem (submenu, SWT.PUSH);
    //		menuItem.addListener(SWT.Selection, new Listener()
    //		{
    //			public void handleEvent(Event e)
    //			{
    //				System.out.println ("Create");
    //			}
    //		});
    //		menuItem.setText("Create &New\tCtrl+N");
    //		menuItem.setAccelerator(SWT.MOD1 + 'N');

    /*
     * Active hosts file location
     */
    label = new Label(sShell, SWT.NONE);
    label.setBounds(new Rectangle(15, 10, 692, 15));

    switchHostsFileButton = new Button(sShell, SWT.NONE);
    switchHostsFileButton.setBounds(new Rectangle(330, 682, 103, 26));
    switchHostsFileButton.setText("Switch");

    switchHostsFileButton.addSelectionListener(
        new org.eclipse.swt.events.SelectionAdapter() {
          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}

          @Override
          public void widgetSelected(SelectionEvent e) {
            openSwitchDialog(sShell);
          }
        });

    minimizeToTrayButton = new Button(sShell, SWT.NONE);
    minimizeToTrayButton.setBounds(new Rectangle(451, 682, 108, 28));
    minimizeToTrayButton.setText("Hide");
    exitButton = new Button(sShell, SWT.NONE);
    exitButton.setBounds(new Rectangle(574, 683, 117, 28));
    exitButton.setText("Exit");

    /*
     * Active file
     */
    activeHostsFileStyledText =
        new StyledText(sShell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
    activeHostsFileStyledText.setText("");
    activeHostsFileStyledText.setTabs(5);
    activeHostsFileStyledText.setBounds(new Rectangle(15, 33, 694, 616));
  }
Exemple #15
0
  public GUI(String Profile, NetworkInterface NetObj) {

    MainDisplay = new Display();
    MainShell = new Shell(MainDisplay);
    Updater = new GUIUpdaterThread(NetObj, this);
    Updater.setDaemon(true);

    // restartOpt=false;
    if (Profile.equals("SERVER") == true) {
      // FIX THIS ASAP
      UserProfile = "SERVER";
      MainServer = (JTServer) NetObj;
      MainServer.test();
      System.out.println(
          "GUI invoked with " + MainServer.getLocalUserIP() + ":" + MainServer.getLocalUserPort());
      MainClient = null;
    } else if (Profile.equals("CLIENT") == true) {
      // FIX THIS ASAP
      UserProfile = "CLIENT";
      MainClient = (JTClient) NetObj;
      MainClient.test();
      MainServer = null;
      System.out.println(
          "GUI invoked with target " + MainClient.getTargetIP() + ":" + MainClient.getTargetPort());
      System.out.println(
          "and client "
              + MainClient.getLocalUserName()
              + "@"
              + MainClient.getLocalUserIP()
              + ":"
              + MainClient.getLocalUserPort());
    } else {
      confirmWin(
          MainShell,
          "Internal Error! No extension of JTNetworkInterface active!",
          jeremeTalk.JTC.OK);
      destroy();
    }

    Calibri = new Font(MainDisplay, "Calibri", 12, SWT.NORMAL);

    Red = new Color(MainDisplay, 0x80, 0, 0);
    Green = new Color(MainDisplay, 0, 0x80, 0);
    Blue = new Color(MainDisplay, 0, 0, 0x80);
    White = new Color(MainDisplay, 0xFF, 0xFF, 0xFF);
    Black = new Color(MainDisplay, 0, 0, 0);
    Gray = new Color(MainDisplay, 0xCC, 0xCC, 0xCC);

    GridLayout GlobalWinGL = new GridLayout();
    GlobalWinGL.numColumns = 3;
    GlobalWinGL.marginHeight = 10;
    GlobalWinGL.marginWidth = 10;
    GlobalWinGL.verticalSpacing = 5;
    GlobalWinGL.horizontalSpacing = 5;

    MainShell.setLayout(GlobalWinGL);

    initWidgets();

    addWidgetListeners();

    MainShell.setMenuBar(GlobalMainMenu);
    MainShell.pack();

    MainShell.setLocation(centralize(MainDisplay.getPrimaryMonitor().getBounds(), MainShell));

    MainShell.setText(
        "JeremeTalk v1.0 : Welcome " + NetObj.getLocalUserName() + " | You are " + UserProfile);

    MainShell.open();
    Updater.start();
    while (!MainShell.isDisposed()) {
      if (!MainDisplay.readAndDispatch()) MainDisplay.sleep();
    }
    if (MainServer == null) MainClient.freePort();
    else MainServer.freePort();
    Updater.kill();
    System.out.println("GUI Destroyed!");
  }
Exemple #16
0
  private void initComponents() {
    if (shell == null) shell = new Shell();
    display = Display.getDefault();
    shell.setLayout(new GridLayout(2, false));
    shell.setText("My 2048");
    Menu menuBar = new Menu(shell, SWT.BAR);
    MenuItem csFileMenu = new MenuItem(menuBar, SWT.CASCADE);
    csFileMenu.setText("File");
    Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
    MenuItem Exit = new MenuItem(menuBar, SWT.PUSH);
    Exit.setText("Exit");
    //
    Exit.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            userCommand = "exit";
            Notify();
            // TODO Auto-generated method stub

          }
        });
    csFileMenu.setMenu(fileMenu);
    MenuItem load = new MenuItem(fileMenu, SWT.PUSH);
    load.setText("Load");
    MenuItem save = new MenuItem(fileMenu, SWT.PUSH);
    save.setText("Save");
    load.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            // TODO Auto-generated method stub
            userCommand = "loadGame";
            Notify();
          }
        });
    save.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent e) {
            // TODO Auto-generated method stub
            userCommand = "saveGame";
            Notify();
          }
        });
    shell.setMenuBar(menuBar);
    if (board == null) board = new Board(shell, SWT.NONE);
    board.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2));
    newGameButton = new Button(shell, SWT.PUSH);
    newGameButton.setText("New game");
    newGameButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    newGameButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            userCommand = "newGame";
            Notify();
          }
        });

    undoMoveButton = new Button(shell, SWT.PUSH);
    undoMoveButton.setText("Undo Move");
    undoMoveButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
    undoMoveButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            userCommand = "undoMove";
            Notify();
          }
        });
    AIButton = new Button(shell, SWT.PUSH);
    AIButton.setText("Run AI");
    // AIButton.setLayoutData(new GridData(SWT.FILL,SWT.LEFT,false,false,1,1));
    // AIButton.setAlignment(SWT.CENTER);
    AIButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            userCommand = "AIGame";
            Notify();
          }
        });
    HintButton = new Button(shell, SWT.PUSH);
    HintButton.setText("Show A Hint");
    HintButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            userCommand = "Hint";
            Notify();
          }
        });

    SaveGameButton = new Button(shell, SWT.PUSH);
    SaveGameButton.setText("Save Game");
    SaveGameButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {
            // TODO Auto-generated method stub

          }

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            userCommand = "saveGame";
            Notify();
          }
        });

    LoadGameButton = new Button(shell, SWT.PUSH);
    LoadGameButton.setText("Load Game");
    LoadGameButton.addSelectionListener(
        new SelectionListener() {

          @Override
          public void widgetDefaultSelected(SelectionEvent arg0) {}

          @Override
          public void widgetSelected(SelectionEvent arg0) {
            userCommand = "loadGame";
            Notify();
          }
        });

    board.addKeyListener(
        new KeyListener() {

          @Override
          public void keyPressed(KeyEvent e) {

            if (e.keyCode == SWT.ARROW_DOWN) userCommand = "down";
            if (e.keyCode == SWT.ARROW_UP) userCommand = "up";
            if (e.keyCode == SWT.ARROW_LEFT) userCommand = "left";
            if (e.keyCode == SWT.ARROW_RIGHT) userCommand = "right";
            Notify();
          }

          @Override
          public void keyReleased(KeyEvent arg0) {
            userCommand = "";
          }
        });
    board.addMouseListener(
        new MouseListener() {
          int xenter, xexit, yenter, yexit;

          @Override
          public void mouseDoubleClick(MouseEvent e) {
            // TODO Auto-generated method stub

          }

          @Override
          public void mouseDown(MouseEvent e) {

            // TODO Auto-generated method stub

            xenter = e.x;
            yenter = e.y;
          }

          @Override
          public void mouseUp(MouseEvent e) {
            // TODO Auto-generated method stub
            xexit = e.x;
            yexit = e.y;
            int xdif, ydif;
            if (xenter != 0 && yenter != 0) {
              xdif = (xenter - xexit);
              ydif = (yenter - yexit);

              if (xdif > 15) userCommand = "left";
              else if (ydif > 15) userCommand = "up";
              else if (xdif < -15) userCommand = "right";
              else if (ydif < -15) userCommand = "down";
              Notify();
            }
          }
        });

    Notify();
  }