Пример #1
0
 public void notifyGenomeServerReachable(boolean reachable) {
   if (loadFromServerMenuItem != null) {
     loadFromServerMenuItem.setEnabled(reachable);
     String tooltip = reachable ? LOAD_GENOME_SERVER_TOOLTIP : CANNOT_LOAD_GENOME_SERVER_TOOLTIP;
     loadFromServerMenuItem.setToolTipText(tooltip);
   }
 }
Пример #2
0
  private void initUI() {

    JMenuBar menubar = new JMenuBar();
    ImageIcon icon = new ImageIcon("exit.png");

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);

    JMenuItem eMenuItem = new JMenuItem("Exit", icon);
    eMenuItem.setMnemonic(KeyEvent.VK_E);
    eMenuItem.setToolTipText("Exit application");
    eMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    file.add(eMenuItem);

    menubar.add(file);

    setJMenuBar(menubar);

    setTitle("Simple menu");
    setSize(300, 200);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }
  /**
   * Constructor creates graphic components and adds them to the JPanel this class inherits from.
   */
  public SlidePuzzleGUI(String solver) {
    // default settings for internal attributes: unsolved 15 puzzle
    nPuzzle = 15;
    solved = false;
    this.solver = solver;
    // create graphics
    // create menu bar with pull down menu for puzzle configuration
    // this needs a menu and a menu item in it
    menuBar = new JMenuBar();
    menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));
    // create a menu and add it to the menu bar.
    JMenu menu = new JMenu("Menu");
    menu.setMnemonic(KeyEvent.VK_M);
    // create menu item
    JMenuItem eMenuItem = new JMenuItem("Configuration");
    eMenuItem.setMnemonic(KeyEvent.VK_C);
    eMenuItem.setToolTipText("Set Puzzle Configuration");
    eMenuItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            createFrame(); // create configuration frame
          }
        });
    menu.add(eMenuItem);
    menuBar.add(menu);

    // create button to solve puzzle in a step by step manner
    // The listener is too lengthy for an anonymous class,
    // code for the listener resides in internal NewGameAction class.
    JButton newGameButton = new JButton("Solve");
    ActionListener gameAction = new NewGameAction();
    newGameButton.addActionListener(gameAction);

    // create control panel that holds the solve button
    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new FlowLayout());
    controlPanel.add(newGameButton);

    // create graphics panel
    initalPuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.INITIALPANEL);
    intermediatePuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.INTERMEDIATEPANEL);
    finalPuzzleGraphics = new GraphicsPanel(nPuzzle, PanelType.GOALPANEL);
    // create and configure a solver
    constructPuzzleSolver();
    // the panel uses a borderlayout
    // the menubar goes on top
    setLayout(new BorderLayout());
    add(menuBar, BorderLayout.NORTH);
    add(controlPanel, BorderLayout.SOUTH);
    add(initalPuzzleGraphics, BorderLayout.WEST);
    add(intermediatePuzzleGraphics, BorderLayout.CENTER);
    add(finalPuzzleGraphics, BorderLayout.EAST);
  }
Пример #4
0
  /**
   * This method initializes addGroupPopupMenuItem
   *
   * @return javax.swing.JMenuItem
   */
  public JMenuItem getAddGroupPopupMenuItem() {
    if (addGroupPopupMenuItem == null) {
      addGroupPopupMenuItem = new JMenuItem();
      addGroupPopupMenuItem.addActionListener(actionListener);
      addGroupPopupMenuItem.setActionCommand(ActionConstants.ADD_GROUP_ACTION);
      addGroupPopupMenuItem.setIcon(ResourceUtil.addGroupIcon);
      addGroupPopupMenuItem.setText(ResourceUtil.getString("button.add"));
      addGroupPopupMenuItem.setToolTipText(
          ResourceUtil.getString("mainframe.button.addgroup.tooltip"));
    }

    return addGroupPopupMenuItem;
  }
Пример #5
0
  private void addMenuToTray() {
    HashMap categories = new HashMap();

    // create menu list
    Iterator plugins = PluginManager.getInstance().getAvailablePlugins();
    plugins = PluginComparator.sortPlugins(plugins);

    while (plugins.hasNext()) {
      Plugin p = (Plugin) plugins.next();

      JMenu category = (JMenu) categories.get(p.getCategory());
      if (category == null) {
        category = new JMenu(p.getCategory());
        categories.put(p.getCategory(), category);

        // copy menu to real one
        if (!p.getCategory().equals("Invisible")) this.trayIcon.add(category);
      }

      ImageIcon icon = new ImageIcon();
      try {
        icon = new ImageIcon(new URL(p.getDirectory() + p.getIcon()));
        icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH));
      } catch (Exception e) {
        // error at icon loading
      }

      JMenuItem menu = new JMenuItem(p.getTitle(), icon);
      menu.setName(p.getName());
      menu.setToolTipText(p.getToolTip());
      menu.addActionListener(this);
      category.add(menu);
    }

    this.trayIcon.addSeparator();

    // windows
    this.trayIcon.add(new WindowMenu(this));

    // open main interface
    JMenuItem menu = new JMenuItem(tr("open"));
    menu.setName("org.lucane.applications.maininterface");
    menu.addActionListener(this);
    this.trayIcon.add(menu);

    // exit
    menu = new JMenuItem(tr("exit"));
    menu.setName("exit");
    menu.addActionListener(this);
    this.trayIcon.add(menu);
  }
Пример #6
0
  /**
   * This method initializes deleteGroupPopupMenuItem.
   *
   * @return javax.swing.JMenuItem
   */
  public JMenuItem getDeleteGroupPopupMenuItem() {
    if (deleteGroupPopupMenuItem == null) {
      deleteGroupPopupMenuItem = new JMenuItem();
      deleteGroupPopupMenuItem.addActionListener(actionListener);
      deleteGroupPopupMenuItem.setActionCommand(ActionConstants.DELETE_GROUP_ACTION);
      deleteGroupPopupMenuItem.setIcon(ResourceUtil.deleteGroupIcon);
      deleteGroupPopupMenuItem.setText(ResourceUtil.getString("button.delete"));
      deleteGroupPopupMenuItem.setToolTipText(
          ResourceUtil.getString("mainframe.button.deletegroup.tooltip"));
      deleteGroupPopupMenuItem.setEnabled(false);
    }

    return deleteGroupPopupMenuItem;
  }
Пример #7
0
  /**
   * This method initializes renameGroupPopupMenuItem.
   *
   * @return javax.swing.JMenuItem
   */
  public JMenuItem getRenameGroupPopupMenuItem() {
    if (renameGroupPopupMenuItem == null) {
      renameGroupPopupMenuItem = new JMenuItem();
      renameGroupPopupMenuItem.addActionListener(actionListener);
      renameGroupPopupMenuItem.setActionCommand(ActionConstants.RENAME_GROUP_ACTION);
      renameGroupPopupMenuItem.setIcon(ResourceUtil.renameGroupIcon);
      renameGroupPopupMenuItem.setText(ResourceUtil.getString("button.rename"));
      renameGroupPopupMenuItem.setToolTipText(
          ResourceUtil.getString("mainframe.button.renamegroup.tooltip"));
      renameGroupPopupMenuItem.setEnabled(false);
    }

    return renameGroupPopupMenuItem;
  }
Пример #8
0
  public storeGUI() {

    // Create Form Frame
    super("Video Store");
    setLayout(new FlowLayout());
    setSize(679, 385);
    setLocation(500, 280);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Menu Bar
    JMenuBar menuBar = new JMenuBar();
    JMenu file = new JMenu("File");
    JMenuItem exit = new JMenuItem("Exit");
    exit.setToolTipText("close");
    exit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(null, "See You!");
            System.exit(0);
          }
        });
    JMenuItem logout = new JMenuItem("Logout");
    logout.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            getContentPane().removeAll();
            JOptionPane.showMessageDialog(null, "logged out!");
            LoginDialog();
          }
        });
    file.add(logout);
    file.add(exit);
    menuBar.add(file);
    setJMenuBar(menuBar);

    lblWelcome = new JLabel("Message", JLabel.LEFT);
    lblWelcome.setFont(new Font("Tahoma", Font.PLAIN, 20));
    lblWelcome.setBounds(0, 0, 336, 25);
    getContentPane().add(lblWelcome);

    // When Frame Loaded
    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowOpened(WindowEvent e) {
            LoginDialog();
          }
        });
  }
Пример #9
0
  private void createCustomerMenu() {

    // Customer menu
    customerMenu = new JMenu("Customer");
    customerMenu.setMnemonic(KeyEvent.VK_C);
    customerMenu.setToolTipText("Customer");
    add(customerMenu);

    // Customer/View All Customers menu item
    viewAllCustomersMenuItem = new JMenuItem("View All Customers");
    viewAllCustomersMenuItem.setToolTipText("View all customers.");
    viewAllCustomersMenuItem.setActionCommand("MainMenu--View All Customers");
    viewAllCustomersMenuItem.addActionListener(actionListener);
    customerMenu.add(viewAllCustomersMenuItem);
  } // end of MainMenu::createCustomerMenu
Пример #10
0
  /**
   * This method initializes addRemoveMembersPopupMenuItem.
   *
   * @return javax.swing.JMenuItem
   */
  public JMenuItem getAddRemoveMembersPopupMenuItem() {
    if (addRemoveMembersPopupMenuItem == null) {
      addRemoveMembersPopupMenuItem = new JMenuItem();
      addRemoveMembersPopupMenuItem.addActionListener(actionListener);
      addRemoveMembersPopupMenuItem.setActionCommand(ActionConstants.ADD_REMOVE_MEMBERS_ACTION);
      addRemoveMembersPopupMenuItem.setIcon(ResourceUtil.addRemoveMembersIcon);
      addRemoveMembersPopupMenuItem.setText(
          ResourceUtil.getString("mainframe.button.addremovemembers"));
      addRemoveMembersPopupMenuItem.setToolTipText(
          ResourceUtil.getString("mainframe.button.addremovemembers.tooltip"));
      addRemoveMembersPopupMenuItem.setEnabled(false);
    }

    return addRemoveMembersPopupMenuItem;
  }
Пример #11
0
  private void createHelpMenu() {

    // Help menu
    helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    helpMenu.setToolTipText("Help");
    add(helpMenu);

    // Help/About menu item
    aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.setMnemonic(KeyEvent.VK_A);
    aboutMenuItem.setToolTipText("Display the About window.");
    aboutMenuItem.setActionCommand("MainMenu--Display About");
    aboutMenuItem.addActionListener(actionListener);
    helpMenu.add(aboutMenuItem);

    // Help/Help menu item
    helpMenuItem = new JMenuItem("Help");
    helpMenuItem.setMnemonic(KeyEvent.VK_H);
    helpMenuItem.setToolTipText("Display the Help window.");
    helpMenuItem.setActionCommand("MainMenu--Display Help");
    helpMenuItem.addActionListener(actionListener);
    helpMenu.add(helpMenuItem);
  } // end of MainMenu::createHelpMenu
Пример #12
0
  private void createFileMenu() {

    // File menu
    fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    fileMenu.setToolTipText("File");
    add(fileMenu);

    // File/Exit menu item
    exitMenuItem = new JMenuItem("Exit");
    exitMenuItem.setMnemonic(KeyEvent.VK_X);
    exitMenuItem.setToolTipText("Exit the program.");
    exitMenuItem.setActionCommand("MainMenu--Exit");
    exitMenuItem.addActionListener(actionListener);
    fileMenu.add(exitMenuItem);
  } // end of MainMenu::createFileMenu
Пример #13
0
  public View(Model model) {

    this.model = model;
    model.makeMeObserver(this);

    frame = new JFrame();

    statusbar = new JLabel(" 0");
    board = new Board();
    frame.add(board);

    JMenuBar menubar = new JMenuBar();
    JMenu file = new JMenu("Settings");
    file.setMnemonic(KeyEvent.VK_F);

    JMenuItem eMenuItem = new JMenuItem("New game");
    eMenuItem.setToolTipText("Start a new game");
    eMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = -1;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });
    file.add(eMenuItem);

    eMenuItem = new JMenuItem("Pause");
    eMenuItem.setMnemonic(KeyEvent.VK_P);
    eMenuItem.setToolTipText("Set pause");
    eMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 1;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });
    file.add(eMenuItem);

    JMenu imp = new JMenu("Set level");
    imp.setMnemonic(KeyEvent.VK_M);

    JMenuItem lvl1 = new JMenuItem("level 1");
    lvl1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 2;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl2 = new JMenuItem("level 2");
    lvl2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 3;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl3 = new JMenuItem("level 3");
    lvl3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 4;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl4 = new JMenuItem("level 4");
    lvl4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 5;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl5 = new JMenuItem("level 5");
    lvl5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 6;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    imp.add(lvl1);
    imp.add(lvl2);
    imp.add(lvl3);
    imp.add(lvl4);
    imp.add(lvl5);

    file.add(imp);

    eMenuItem = new JMenuItem("Table of recorgs");
    eMenuItem.setToolTipText("Show table of records");
    eMenuItem.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            recordDialog ad;
            try {
              ad = new recordDialog();
              ad.setVisible(true);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });
    file.add(eMenuItem);

    eMenuItem = new JMenuItem("Exit");
    eMenuItem.setMnemonic(KeyEvent.VK_C);
    eMenuItem.setToolTipText("Exit application");
    eMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });
    file.add(eMenuItem);

    menubar.add(file);
    frame.setJMenuBar(menubar);

    statusbar.setPreferredSize(new Dimension(-1, 22));
    statusbar.setBorder(LineBorder.createGrayLineBorder());
    frame.add(statusbar, BorderLayout.SOUTH);

    frame.setSize(200, 400);
    frame.setTitle("Tetris");
    frame.setLocationRelativeTo(null);
  }
Пример #14
0
  /**
   * Constructor. Draws the popupmenu.
   *
   * @param panel the parent panel for this popup.
   */
  public UITagTreeLeafPopupMenu(UITagTreePanel panel, Code code, String sGroupID) {
    super(
        LanguageProperties.getString(
            LanguageProperties.TAGS_BUNDLE,
            "UITagTreeLeafPopupMenu.detailsoptions")); //$NON-NLS-1$

    this.sGroupID = sGroupID;

    this.oParent = panel;
    this.code = code;

    /*miMenuItemShow = new JMenuItem("Show Tag Usage");
    miMenuItemShow.setToolTipText("Show a list of nodes which have this tag assigned");
    miMenuItemShow.setMnemonic('S');
    miMenuItemShow.addActionListener(this);
    add(miMenuItemShow);*/

    miMenuItemEdit =
        new JMenuItem(
            LanguageProperties.getString(
                LanguageProperties.TAGS_BUNDLE,
                "UITagTreeLeafPopupMenu.edittagname")); //$NON-NLS-1$
    miMenuItemEdit.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TAGS_BUNDLE,
            "UITagTreeLeafPopupMenu.edittagnameTip")); //$NON-NLS-1$
    miMenuItemEdit.setMnemonic(
        (LanguageProperties.getString(
                LanguageProperties.TAGS_BUNDLE, "UITagTreeLeafPopupMenu.edittagnameMnemonic"))
            .charAt(0)); // $NON-NLS-1$
    miMenuItemEdit.addActionListener(this);
    add(miMenuItemEdit);

    /*miMenuItemRemoveTag = new JMenuItem("Remove From Selected Nodes");
    miMenuItemRemoveTag.setToolTipText("Remove this tag from the selected node on the current view");
    miMenuItemRemoveTag.setMnemonic('R');
    miMenuItemRemoveTag.addActionListener(this);
    add(miMenuItemRemoveTag);*/

    if (!sGroupID.equals("")) { // $NON-NLS-1$
      miMenuItemRemove =
          new JMenuItem(
              LanguageProperties.getString(
                  LanguageProperties.TAGS_BUNDLE,
                  "UITagTreeLeafPopupMenu.removefromgroup")); //$NON-NLS-1$
      miMenuItemRemove.setToolTipText(
          LanguageProperties.getString(
              LanguageProperties.TAGS_BUNDLE,
              "UITagTreeLeafPopupMenu.removefromgroupTip")); //$NON-NLS-1$
      miMenuItemRemove.setMnemonic(
          (LanguageProperties.getString(
                  LanguageProperties.TAGS_BUNDLE,
                  "UITagTreeLeafPopupMenu.removefromgrouptipMnemonic"))
              .charAt(0)); // $NON-NLS-1$
      miMenuItemRemove.addActionListener(this);
      add(miMenuItemRemove);
    }

    miMenuItemDelete =
        new JMenuItem(
            LanguageProperties.getString(
                LanguageProperties.TAGS_BUNDLE, "UITagTreeLeafPopupMenu.deletetag")); // $NON-NLS-1$
    miMenuItemDelete.setToolTipText(
        LanguageProperties.getString(
            LanguageProperties.TAGS_BUNDLE, "UITagTreeLeafPopupMenu.deletetagTip")); // $NON-NLS-1$
    miMenuItemDelete.setMnemonic(
        (LanguageProperties.getString(
                LanguageProperties.TAGS_BUNDLE, "UITagTreeLeafPopupMenu.deletetagMnemonic"))
            .charAt(0)); // $NON-NLS-1$
    miMenuItemDelete.addActionListener(this);
    add(miMenuItemDelete);

    pack();
    setSize(nWidth, nHeight);
  }
Пример #15
0
  private void createMenuBar() {

    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    this.add(file);

    JMenuItem newMap = new JMenuItem("New");
    newMap.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            NewMapDialog nmd = new NewMapDialog();
            MapSize newMapSize = nmd.showDialog();
            if (newMapSize != null) {
              map.initializeGrid(newMapSize);
            }
          }
        });
    newMap.setToolTipText("Make a new map");
    newMap.setMnemonic(KeyEvent.VK_N);
    file.add(newMap);

    JMenuItem loadMap = new JMenuItem("Open");
    loadMap.setToolTipText("Open saved new map");
    loadMap.setMnemonic(KeyEvent.VK_O);
    loadMap.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            controller.loadMap();
          }
        });
    file.add(loadMap);

    JMenuItem saveMap = new JMenuItem("Save");
    saveMap.setToolTipText("Save map");
    saveMap.setMnemonic(KeyEvent.VK_S);
    saveMap.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JFileChooser saveMapDialog = new JFileChooser("D:\\");
            if (saveMapDialog.showSaveDialog((JMenuItem) e.getSource())
                == JFileChooser.APPROVE_OPTION) {
              try {
                File mapSaveFile = saveMapDialog.getSelectedFile();
                mapSaveFile = new File(mapSaveFile.toString() + ".jh3m");
                if (!mapSaveFile.exists()) {
                  mapSaveFile.createNewFile();
                }
                FileOutputStream mapSaveStream = new FileOutputStream(mapSaveFile);
                ObjectOutputStream mapSaveObjectStream = new ObjectOutputStream(mapSaveStream);
                SavedMap currentMapToSave = new SavedMap(map.getMapSize(), map.getMapCells());
                mapSaveObjectStream.writeObject(currentMapToSave);
                mapSaveObjectStream.close();
                mapSaveStream.close();
                JOptionPane.showMessageDialog(
                    null, "Zapis udany!", "Zapisano", JOptionPane.INFORMATION_MESSAGE);

              } catch (Exception ex) {
                JOptionPane.showMessageDialog(
                    null, ex.toString(), "ERROR", JOptionPane.ERROR_MESSAGE);
                ex.printStackTrace();
              }
            }
          }
        });
    file.add(saveMap);

    JMenu edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);
    this.add(edit);

    JMenuItem eShowGrid = new JMenuItem("Show/Hide grid");
    eShowGrid.setToolTipText("Shows/Hides grid on the map");
    eShowGrid.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent event) {
            map.showHideGrid();
          }
        });
    edit.add(eShowGrid);
  }
Пример #16
0
  // code used to create the menu bar
  public JMenuBar menuBar() {
    JMenuBar menuBar;
    JMenu menu, submenu;
    JMenuItem menuItem;

    menuBar = new JMenuBar();
    menu = new JMenu("File");

    // creates open option
    menuItem = new JMenuItem("Open", KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open a Previously Saved File");
    menu.add(menuItem);
    menuItem.addActionListener(new FileOpenListener());
    menu.addSeparator();

    // creates save option
    menuItem = new JMenuItem("Save", KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Save File Data");
    menu.add(menuItem);
    menuItem.addActionListener(new FileSaveListener());
    menu.addSeparator();

    // creates close option
    menuItem = new JMenuItem("Exit", KeyEvent.VK_A);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Close Program");
    menu.add(menuItem);
    menuItem.addActionListener(new FileExitListener());

    menuBar.add(menu);

    // new menu option for Route
    menu = new JMenu("Route");

    menuItem = new JMenuItem("Add");
    menu.add(menuItem);
    menuItem.addActionListener(new RouteAddListener());

    menuItem = new JMenuItem("Remove");
    menu.add(menuItem);
    menuItem.addActionListener(new RouteRemoveListener());

    menuItem = new JMenuItem("Search Routes");
    menu.add(menuItem);
    menuItem.addActionListener(new RouteFindListener());

    menuItem = new JMenuItem("Find Path");
    menu.add(menuItem);
    menuItem.addActionListener(new PathFindListener());

    menuBar.add(menu);

    // new menu option for Airport

    menu = new JMenu("Airport");

    menuItem = new JMenuItem("Open");
    menu.add(menuItem);
    menuItem.addActionListener(new AirOpenListener());

    menuItem = new JMenuItem("Close");
    menu.add(menuItem);
    menuItem.addActionListener(new AirCloseListener());

    menuItem = new JMenuItem("Add");
    menu.add(menuItem);
    menuItem.addActionListener(new AirAddListener());

    menuItem = new JMenuItem("Delete");
    menu.add(menuItem);
    menuItem.addActionListener(new AirDeleteListener());

    menuItem = new JMenuItem("Airport Route Information");
    menuItem.setToolTipText("Click to search all routes at a given airport.");
    menu.add(menuItem);
    menuItem.addActionListener(new AirSearchListener());

    menuItem = new JMenuItem("List Airports");
    menu.add(menuItem);
    menuItem.addActionListener(new AirAllListener());

    menuBar.add(menu);

    // new menu option for Help
    menu = new JMenu("Help");

    menuItem = new JMenuItem("User Manual");
    menu.add(menuItem);
    menuItem.addActionListener(new HelpManualListener());

    menuBar.add(menu);

    return menuBar;
  }
Пример #17
0
  public MainFrameV3() {
    setTitle("Revision Annotation Tool");

    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    int width = gd.getDisplayMode().getWidth();
    int height = gd.getDisplayMode().getHeight();
    width = (int) (width * 0.95);
    height = (int) (height * 0.95);
    setSize(width, height);
    // setSize(1000, 800);
    // pack();
    JMenuBar menuBar = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item = new JMenuItem("Load File");
    item.setToolTipText("Load the spreadsheet file for annotation");
    JMenuItem item2 = new JMenuItem("Export to File");
    item2.setToolTipText("Export the annotation to a specified location");
    JMenuItem saveItem = new JMenuItem("Save");
    saveItem.setToolTipText("Save the annotation to the current file");
    JMenuItem itemLoadService = new JMenuItem("Load From Server");
    itemLoadService.setToolTipText("Load the spreadsheet file from server for annotation");
    JMenuItem itemUploadService = new JMenuItem("Upload To Server");
    itemUploadService.setToolTipText("Upload the spreadsheet file to the server");

    JMenuItem item3 = new JMenuItem("Import the source file(Old Draft)");
    item3.setToolTipText(
        "Not implemented yet, load the original source file to generate the spreadsheet file");
    JMenuItem item4 = new JMenuItem("Import the destination file(New Draft)");
    item4.setToolTipText(
        "Not implemented yet, load the revised source file to generate the spreadsheet file");
    JMenuItem item5 = new JMenuItem("Generate annotation file");
    item5.setToolTipText(
        "Not implemented yet, Generate the spreadsheet file using the imported files");
    JMenu menuHelp = new JMenu("Help");

    JMenu menuDemo = new JMenu("Run");

    saveItem.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            // TODO Auto-generated method stub
            try {
              panel.registerRevision();
              boolean isSuccess = save();
              if (isSuccess) {
                JOptionPane.showMessageDialog(MainFrameV3.this, "File saved.");
              } else {
                JOptionPane.showMessageDialog(MainFrameV3.this, "File save fail!");
              }
            } catch (Exception e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
            }
          }
        });

    itemLoadService.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            try {
              JTextField addressField = new JTextField("http://lrdc-apps.lrdc.pitt.edu:8080");
              JTextField usernameField = new JTextField("test");
              JPanel myPanel = new JPanel();
              myPanel.setSize(600, 400);
              myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS));
              myPanel.add(new JLabel("ServerAddress:"));
              myPanel.add(addressField);

              myPanel.add(new JLabel("Username:"******"OptionPane.minimumSize", new Dimension(500, 200));
              int result =
                  JOptionPane.showConfirmDialog(
                      null,
                      myPanel,
                      "Please Enter Server Address and user name",
                      JOptionPane.OK_CANCEL_OPTION);
              if (result == JOptionPane.OK_OPTION) {
                serverAddress = addressField.getText();
                username = usernameField.getText();
                loadFromService(serverAddress, username);
              }
            } catch (Exception e1) {
              // TODO Auto-generated catch block
              e1.printStackTrace();
              JOptionPane.showMessageDialog(MainFrameV3.this, e1.getMessage());
            }
          }
        });

    itemUploadService.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(
                MainFrameV3.this, uploadToService(serverAddress, username));
          }
        });

    item.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            int returnVal = fc.showOpenDialog(MainFrameV3.this);

            if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              try {
                MainFrameV3.this.load(file.getAbsolutePath());
                currentPath = file.getAbsolutePath();
              } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }
            } else {

            }
          }
        });

    item2.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            int returnVal = fc.showOpenDialog(MainFrameV3.this);

            if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              try {
                panel.registerRevision();
                boolean isSuccess = MainFrameV3.this.export(file.getAbsolutePath());
                if (isSuccess) {
                  JOptionPane.showMessageDialog(MainFrameV3.this, "File saved.");
                } else {
                  JOptionPane.showMessageDialog(MainFrameV3.this, "File save fail!");
                }
              } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
              }

            } else {

            }
          }
        });

    menu.add(item);
    menu.add(item2);
    menu.add(saveItem);
    menu.add(new JSeparator());
    menu.add(itemLoadService);
    menu.add(itemUploadService);

    /*
     * item3.setEnabled(false); menu.add(item3); item4.setEnabled(false);
     * menu.add(item4); item5.setEnabled(false); menu.add(item5);
     */

    JMenuItem menuCode = new JMenuItem("Coding Manual");
    menuCode.setEnabled(false);
    menuHelp.add(menuCode);
    JMenuItem menuDemoItem = new JMenuItem("Demo annotations");
    menuDemoItem.setEnabled(true);
    menuDemoItem.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // System.out.println("DID SHOW");
            JFrame f = new JFrame();
            f.setSize(800, 600);
            f.setContentPane(displayPanel);
            f.show();
          }
        });

    menuDemo.add(menuDemoItem);

    menuBar.add(menu);
    menuBar.add(menuHelp);
    menuBar.add(menuDemo);
    this.setJMenuBar(menuBar);
  }