public MapViewPopup() {
    entityInfoMenuItem = new JMenuItem("Entity Info");
    entityInfoMenuItem.addActionListener(this);
    add(entityInfoMenuItem);

    JMenu markerMenu = new JMenu("Marker");
    add(markerMenu);
    createMarkerMenuItem = new JMenuItem("Create");
    createMarkerMenuItem.addActionListener(this);
    markerMenu.add(createMarkerMenuItem);
    removeMarkerMenuItem = new JMenuItem("Remove");
    removeMarkerMenuItem.addActionListener(this);
    markerMenu.add(removeMarkerMenuItem);
    loadMarkersMenuItem = new JMenuItem("Load All");
    loadMarkersMenuItem.addActionListener(this);
    markerMenu.add(loadMarkersMenuItem);
    saveMarkersMenuItem = new JMenuItem("Save All");
    saveMarkersMenuItem.addActionListener(this);
    markerMenu.add(saveMarkersMenuItem);

    clearMenuItem = new JMenuItem("Clear M&T");
    clearMenuItem.addActionListener(this);
    add(clearMenuItem);

    functionsMenuItem = new JMenuItem("Functions");
    functionsMenuItem.addActionListener(this);
    add(functionsMenuItem);

    addSeparator();
    debugMenuItem = new JCheckBoxMenuItem("Debug Mode");
    debugMenuItem.addActionListener(this);
    add(debugMenuItem);
  }
  /**
   * Gets the help menu.
   *
   * @return the help menu
   */
  public JMenu getHelpMenu() {
    JMenu menu = new JMenu("Help");
    menu.setMnemonic('H');

    menu.add(menuItem("About Lobo", 'A', new AboutAction(this, window)));
    menu.addSeparator();
    menu.add(
        menuItem(
            "Project Home Page",
            this.actionPool.createNavigateAction(
                "http://sourceforge.net/projects/loboevolution/")));
    menu.add(
        menuItem(
            "Development Home Page",
            this.actionPool.createNavigateAction("https://github.com/oswetto/Loboevolution/")));
    menu.add(
        menuItem(
            "Bug tracking",
            this.actionPool.createNavigateAction(
                "https://github.com/oswetto/Loboevolution/issues/")));
    menu.addSeparator();
    menu.add(
        menuItem(
            "Wiki",
            this.actionPool.createNavigateAction(
                "http://sourceforge.net/p/loboevolution/wiki/Home/")));
    menu.add(
        menuItem(
            "Discussion Forum",
            this.actionPool.createNavigateAction(
                "http://sourceforge.net/p/loboevolution/discussion/")));

    return menu;
  }
  /** Populate searchers. */
  private void populateSearchers() {
    JMenu searchersMenu = this.searchersMenu;
    searchersMenu.removeAll();
    final ToolsSettings settings = ToolsSettings.getInstance();
    Collection<SearchEngine> searchEngines = settings.getSearchEngines();
    SearchEngine selectedEngine = settings.getSelectedSearchEngine();
    if (searchEngines != null) {
      for (SearchEngine se : searchEngines) {
        final SearchEngine finalSe = se;
        JRadioButtonMenuItem item = new JRadioButtonMenuItem();
        item.setAction(
            new AbstractAction() {

              private static final long serialVersionUID = 1L;

              @Override
              public void actionPerformed(ActionEvent e) {
                settings.setSelectedSearchEngine(finalSe);
                settings.save();
                ComponentSource.this.updateSearchButtonTooltip();
              }
            });
        item.setSelected(se == selectedEngine);
        item.setText(se.getName());
        item.setToolTipText(se.getDescription());
        searchersMenu.add(item);
      }
    }
  }
  protected JMenu buildFileMenu() {
    JMenu file = new JMenu("File");
    JMenuItem newWin = new JMenuItem("New");
    JMenuItem open = new JMenuItem("Open");
    JMenuItem quit = new JMenuItem("Quit");

    newWin.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            newDocument();
          }
        });

    open.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            openDocument();
          }
        });

    quit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            quit();
          }
        });

    file.add(newWin);
    file.add(open);
    file.addSeparator();
    file.add(quit);
    return file;
  }
  protected JMenuBar createMenuBar() {
    JMenuBar bar = new JMenuBar();
    JMenu homeMenu = new JMenu("Homing");
    bar.add(homeMenu);

    // adding the appropriate homing options for your endstop configuration
    for (AxisId axis : AxisId.values()) {
      Endstops endstops = machine.getDriver().getMachine().getEndstops(axis);
      if (endstops != null) {
        if (endstops.hasMin == true)
          homeMenu.add(
              makeHomeItem("Home " + axis.name() + " to minimum", EnumSet.of(axis), false));
        if (endstops.hasMax == true)
          homeMenu.add(makeHomeItem("Home " + axis.name() + " to maximum", EnumSet.of(axis), true));
      }
    }

    /*
    homeMenu.add(new JSeparator());
    homeMenu.add(makeHomeItem("Home XY+",EnumSet.of(Axis.X,Axis.Y),true));
    homeMenu.add(makeHomeItem("Home XY-",EnumSet.of(Axis.X,Axis.Y),false));
    homeMenu.add(makeHomeItem("Home all+",EnumSet.allOf(Axis.class),true));
    homeMenu.add(makeHomeItem("Home all-",EnumSet.allOf(Axis.class),false));
    */
    return bar;
  }
Example #6
0
  // {{{ createMacrosMenu() method
  private void createMacrosMenu(JMenu menu, Vector vector, int start) {
    Vector<JMenuItem> menuItems = new Vector<JMenuItem>();
    int maxItems = jEdit.getIntegerProperty("menu.spillover", 20);
    JMenu subMenu = null;
    for (int i = start; i < vector.size(); i++) {
      if (i != start && i % maxItems == 0) {
        subMenu = new JMenu(jEdit.getProperty("common.more"));
        createMacrosMenu(subMenu, vector, i);
        break;
      }
      Object obj = vector.elementAt(i);
      if (obj instanceof String) {
        menuItems.add(
            new EnhancedMenuItem(
                jEdit.getProperty(obj + ".label"), (String) obj, jEdit.getActionContext()));
      } else if (obj instanceof Vector) {
        Vector subvector = (Vector) obj;
        String name = (String) subvector.elementAt(0);
        JMenu submenu = new JMenu(jEdit.getProperty("macros.folder." + name + ".label", name));
        createMacrosMenu(submenu, subvector, 1);
        if (submenu.getMenuComponentCount() != 0) menuItems.add(submenu);
      }
    }

    Collections.sort(menuItems, new MenuItemTextComparator());

    if (subMenu != null) menuItems.add(subMenu);

    for (int i = 0; i < menuItems.size(); i++) {
      menu.add(menuItems.get(i));
    }
  } // }}}
  public void adjustListMenuBar() {
    JMenuItem menuItem;
    Action act;
    String itemLabel;
    boolean enableState;
    boolean inEditState;
    boolean allowAdds;
    ICFInternetTopProjectObj selectedObj = getSwingFocusAsTopProject();
    CFJPanel.PanelMode mode = getPanelMode();
    if (mode == CFJPanel.PanelMode.Edit) {
      inEditState = true;
      if (getSwingContainer() != null) {
        allowAdds = true;
      } else {
        allowAdds = false;
      }
    } else {
      inEditState = false;
      allowAdds = false;
    }
    if (selectedObj == null) {
      enableState = false;
    } else {
      enableState = true;
    }

    if (actionViewSelected != null) {
      actionViewSelected.setEnabled(enableState);
    }
    if (actionEditSelected != null) {
      actionEditSelected.setEnabled(inEditState && enableState);
    }
    if (actionDeleteSelected != null) {
      actionDeleteSelected.setEnabled(inEditState && enableState);
    }
    if (actionAddTopProject != null) {
      actionAddTopProject.setEnabled(allowAdds);
    }

    if (menuAdd != null) {
      menuAdd.setEnabled(allowAdds);
    }
    if (menuSelected != null) {
      menuSelected.setEnabled(enableState);
      int itemCount = menuSelected.getItemCount();
      for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
        menuItem = menuSelected.getItem(itemIdx);
        act = menuItem.getAction();
        if (act != null) {
          if (act == actionViewSelected) {
            menuItem.setEnabled(enableState);
          } else if (act == actionEditSelected) {
            menuItem.setEnabled(inEditState && enableState);
          } else if (act == actionDeleteSelected) {
            menuItem.setEnabled(inEditState && enableState);
          }
        }
      }
    }
  }
  private void createMenu(JFrame frame) {
    menuBar = new JMenuBar();

    // First menu: "File"
    fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    newMenuItem = new JMenuItem("New...", KeyEvent.VK_N);
    newMenuItem.addActionListener(this);
    fileMenu.add(newMenuItem);

    saveMenuItem = new JMenuItem("Save...", KeyEvent.VK_S);
    saveMenuItem.addActionListener(this);
    fileMenu.add(saveMenuItem);

    openMenuItem = new JMenuItem("Open...", KeyEvent.VK_O);
    openMenuItem.addActionListener(this);
    fileMenu.add(openMenuItem);

    fileMenu.addSeparator();

    exitMenuItem = new JMenuItem("Exit...", KeyEvent.VK_X);
    exitMenuItem.addActionListener(this);
    fileMenu.add(exitMenuItem);

    // Add menubar to frame
    frame.setJMenuBar(menuBar);
  }
Example #9
0
  ManWindow() {
    try {
      this.setIconImage(ImageIO.read(new File("ImageMan.png")));
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    label = new JLabel();
    mainboard = new ImagePanel();
    add(mainboard, BorderLayout.CENTER);

    collection = new JMenu("图片集");
    changeDir = new JMenuItem("进入文件夹");
    changeDir.addActionListener(this);
    collection.add(changeDir);
    startServer = new JMenuItem("启动");
    startServer.addActionListener(this);
    serverMenu = new JMenu("网络服务");
    serverMenu.add(startServer);
    mainbar = new JMenuBar();
    mainbar.add(collection);
    mainbar.add(serverMenu);
    setJMenuBar(mainbar);

    mainview = new ImageThumbView(System.getProperty("user.home"), mainboard, this);
    add(mainview, BorderLayout.WEST);
    setBounds(100, 100, 500, 500);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  /** Set-Up Method to create the file menu */
  private void createNewFileMenu() {
    JMenuItem newBuild;
    newBuild = new JMenuItem("New Build");
    newBuild.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent arg0) {
            new NewBuildWindow();
          }
        });
    JMenuItem saveBuild;
    saveBuild = new JMenuItem("Save Build");
    saveBuild.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent arg0) {
            try {
              if (MainWindow.getMainWindow().getLeftPanel().getCurBuild() != null) {
                try {
                  MainWindow.getMainWindow().getLeftPanel().getCurBuild().writeToDir("res/files/");
                } catch (FileAlreadyExistsException e) {
                  int overwrite =
                      JOptionPane.showConfirmDialog(
                          MainWindow.getMainWindow(),
                          "A Build for this Hero already exists in your Directory! Overwrite?");
                  if (overwrite == 0) {
                    MainWindow.getMainWindow()
                        .getLeftPanel()
                        .getCurBuild()
                        .writeToDirOverwrite("res/files/");
                  }
                }
              } else {
                JOptionPane.showMessageDialog(
                    MainWindow.getMainWindow(), "You can't save a non-existant Build!");
              }
            } catch (HeadlessException e) { // Can't Happen

              e.printStackTrace();
            }
          }
        });
    JMenuItem openBuild;
    openBuild = new JMenuItem("Open Build");
    // needs Check for real ItemBuild File
    openBuild.addMouseListener(
        new MouseAdapter() {
          public void mousePressed(MouseEvent arg0) {
            final JFileChooser fc = new JFileChooser();
            fc.setCurrentDirectory(new File("/res/files"));
            int returnVal = fc.showOpenDialog(MainWindow.getMainWindow());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              File opened = fc.getSelectedFile();
              MainWindow.getMainWindow().getLeftPanel().addItemBuild(new ItemBuild(opened));
            }
          }
        });
    fileMenu = new JMenu("File");
    fileMenu.add(newBuild);
    fileMenu.add(saveBuild);
    fileMenu.add(openBuild);
  }
 /** Lay out the elements for the main window */
 protected void buildFrame() {
   GridBagConstraints c = new GridBagConstraints();
   GridBagLayout layout = new GridBagLayout();
   frame = new JFrame();
   menuBar = frame.getJMenuBar();
   if (menuBar == null) {
     menuBar = new JMenuBar();
     frame.setJMenuBar(menuBar);
   }
   basicListener = new BasicListener();
   JMenu menu = new JMenu("File");
   JMenuItem readDirectory = new JMenuItem("Read Directory");
   readDirectory.addActionListener(basicListener);
   readDirectory.setActionCommand("READALL");
   menu.add(readDirectory);
   JMenuItem exitProgram = new JMenuItem("ExitProgram");
   exitProgram.addActionListener(basicListener);
   exitProgram.setActionCommand("EXIT");
   menu.add(exitProgram);
   menuBar.add(menu);
   JPanel panel = new JPanel();
   c.fill = GridBagConstraints.BOTH;
   c.gridwidth = GridBagConstraints.REMAINDER;
   c.weightx = 3.0f;
   panel.setLayout(layout);
   extraButtonItems(panel, layout);
   c.weighty = 2.0f;
   layout.setConstraints(panel, c);
   frame.add(panel);
   frame.setSize(400, 400);
   frame.setVisible(true);
 }
Example #12
0
  protected final void initMenu() {
    mainFrame.setJMenuBar(menuBar);

    menuBar.add(fileMenu);

    fileOpen.addActionListener(new FileAddListener());
    fileMenu.add(fileOpen);

    fileClose.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    fileMenu.add(fileClose);

    // used for language selection, for future add-on
    /*
    menuBar.add(languageMenu);
    eng.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setTextByLocale(new Locale("en", "us"));
    }
    });
    languageMenu.add(eng);
    chn.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setTextByLocale(new Locale("zh", "cn"));
    }
    });
    languageMenu.add(chn);
    */
  }
Example #13
0
  /**
   * Returns a JMenu object for use in the JMenuBar.
   *
   * @return JMenu
   */
  private JMenu getAboutMenu() {

    JMenu aboutMenu = new JMenu("Om");
    aboutMenu.setMnemonic('o');

    JMenuItem tipsItem = new JMenuItem("Dagens tips");
    tipsItem.setMnemonic('d');
    tipsItem.addActionListener(evt -> dailyTips());

    JMenuItem aboutItem = new JMenuItem("Om Fargestiften");
    aboutItem.setMnemonic('o');
    aboutItem.addActionListener(
        evt -> {
          AboutDialog about = new AboutDialog();

          internalFrameSize = about.getSize();
          about.setLocation(
              (desktopSize.width - internalFrameSize.width) / 2,
              (desktopSize.height - internalFrameSize.height) / 2);

          about.setVisible(true);

          jDesktopPane.add(about, JLayeredPane.MODAL_LAYER);
          try {
            about.setSelected(true);
          } catch (PropertyVetoException e) {
            e.printStackTrace();
          }
        });

    aboutMenu.add(tipsItem);
    aboutMenu.add(aboutItem);

    return aboutMenu;
  }
Example #14
0
  public ImageViewerFrame() {
    logger.entering("ImageViewerFrame", "<init>");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    // set up menu bar
    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);
    JMenu menu = new JMenu("File");
    menuBar.add(menu);

    JMenuItem openItem = new JMenuItem("Open");
    menu.add(openItem);
    openItem.addActionListener(new FileOpenListener());
    JMenuItem exitItem = new JMenuItem("Exit");
    menu.add(exitItem);
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            logger.fine("Exiting.");
            System.exit(0);
          }
        });
    // use a label to display the images
    label = new JLabel();
    add(label);
    logger.exiting("ImageViewerFrame", "<init>");
  }
  public void testCreatesBlockamonMenuCorrectly() {
    Blockamon blockamon = new Blockamon(ElementType.BUG);
    _player.addToParty(blockamon);
    JMenu menu = _constructor.createBlockamonMenu();

    assertNameAndText(menu, "Blockamon", "Blockamon");

    assertEquals("Number of menu items was not correct", 2, menu.getItemCount());

    JMenuItem blockamonMenuItem = menu.getItem(0);
    assertNameAndText(
        blockamonMenuItem,
        blockamon.elementType() + "0",
        blockamon.name()
            + ", "
            + blockamon.level()
            + ", "
            + blockamon.currentHp()
            + "/"
            + blockamon.maxHp());
    assertNotNull("Blockamon menu action not set", blockamonMenuItem.getAction());
    assertEquals(BlockamonAction.class, blockamonMenuItem.getAction().getClass());

    JMenuItem backItemMenu = menu.getItem(1);
    assertNotNull("Back item menu was not added", backItemMenu);
    assertEquals("Back item text was not right", "Back", backItemMenu.getText());
    assertNotNull("Back action was not set", backItemMenu.getAction());
    assertEquals(BackAction.class, backItemMenu.getAction().getClass());
  }
Example #16
0
  protected JPopupMenu createPopUpMenu() {
    JPopupMenu menu = new JPopupMenu();
    JMenu saveMenu = new JMenu("Save As..");
    menu.add(saveMenu);

    JMenuItem item = new JMenuItem("PNG");
    item.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            saveImage("PNG");
          }
        });
    saveMenu.add(item);

    item = new JMenuItem("JPEG");
    item.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            saveImage("JPEG");
          }
        });
    saveMenu.add(item);

    JMenu[] menus = createMenus();
    if (menus != null) {
      for (int i = 0; i < menus.length; i++) {
        menu.add(menus[i]);
      }
    }

    return menu;
  }
    public CFrame() {
      super("Converter between Imperial and Metric.");

      setDefaultCloseOperation(EXIT_ON_CLOSE);

      JMenu menu = new JMenu("Application");
      menu.setBackground(white);
      menu.setMnemonic(KeyEvent.VK_A);

      // quit item
      JMenuItem item = new JMenuItem("Quit");
      item.setBackground(white);
      item.setMnemonic(KeyEvent.VK_Q);
      item.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.gc();
              System.exit(0);
            }
          });
      menu.add(item);

      JMenuBar menuBar = new JMenuBar();
      menuBar.setBackground(white);
      menuBar.add(menu);
      setJMenuBar(menuBar);

      setVisible(true);
    } // end of CFrame constructor
  @Override
  protected JMenu getMenu() {
    final JMenu menu = new JMenu("Projects");
    menu.setMnemonic("HK_MENU_PROJECTS".charAt(0));

    return menu;
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddTopProject = new ActionAddTopProject();
     if (container instanceof ICFInternetDomainBaseObj) {
       menuItem = new JMenuItem(actionAddTopProject);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionTopProject();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionTopProject();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionTopProject();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
 /*
  * The following method creates the font menu
  * postcondition: returns the JMenu for the font menu.
  */
 public JMenu createFontMenu() {
   JMenu menu = new JMenu(new String("Font"));
   menu.add(createFontNameMenu());
   menu.add(createFontSizeMenu());
   menu.add(createFontStyleMenu());
   return menu;
 } // end createFontMenu method
Example #21
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);
  }
  /**
   * Uses the main help menu, and adds a few extra options. If/when there's Android-specific
   * documentation, we'll switch to that.
   */
  public JMenu buildHelpMenu() {
    JMenu menu = super.buildHelpMenu();
    JMenuItem item;

    menu.addSeparator();

    item = new JMenuItem("Processing for Android Wiki");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Platform.openURL("http://wiki.processing.org/w/Android");
          }
        });
    menu.add(item);

    item = new JMenuItem("Android Developer Site");
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Platform.openURL("http://developer.android.com/");
          }
        });
    menu.add(item);

    return menu;
  }
Example #23
0
  /**
   * Returns true if the specified component exists in the submenu hierarchy.
   *
   * @param c the <code>Component</code> to be tested
   * @return true if the <code>Component</code> exists, false otherwise
   */
  @Override
  public boolean isMenuComponent(Component c) {
    // Are we in the MenuItem part of the menu
    if (c == this) return true;
    // Are we in the PopupMenu?
    if (c instanceof JPopupMenu) {
      JPopupMenu comp = (JPopupMenu) c;
      if (comp == this.getPopupMenu()) return true;
    }
    // Are we in a Component on the PopupMenu
    int ncomponents = this.getMenuComponentCount();
    Component[] component = this.getMenuComponents();
    for (int i = 0; i < ncomponents; i++) {
      Component comp = component[i];
      // Are we in the current component?
      if (comp == c) return true;
      // Hmmm, what about Non-menu containers?

      // Recursive call for the Menu case
      if (comp instanceof JMenu) {
        JMenu subMenu = (JMenu) comp;
        if (subMenu.isMenuComponent(c)) return true;
      }
    }
    return false;
  }
 public JMenuBar getPanelMenuBar() {
   if (panelMenuBar == null) {
     JMenuItem menuItem;
     ICFLibAnyObj container = getSwingContainer();
     panelMenuBar = new JMenuBar();
     menuAdd = new JMenu("Add");
     actionAddSecGroupMember = new ActionAddSecGroupMember();
     if (container instanceof ICFSecuritySecGroupObj) {
       menuItem = new JMenuItem(actionAddSecGroupMember);
       menuAdd.add(menuItem);
     }
     if (getSwingContainer() != null) {
       panelMenuBar.add(menuAdd);
     }
     menuSelected = new JMenu("Selected");
     menuSelected.setEnabled(false);
     actionViewSelected = new ViewSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionViewSelected);
     menuSelected.add(menuItem);
     actionEditSelected = new EditSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionEditSelected);
     menuSelected.add(menuItem);
     actionDeleteSelected = new DeleteSelectedActionSecGroupMember();
     menuItem = new JMenuItem(actionDeleteSelected);
     menuSelected.add(menuItem);
     panelMenuBar.add(menuSelected);
   }
   return (panelMenuBar);
 }
Example #25
0
 private JMenu createMenu(String menuName, String[] itemArr) {
   JMenu menu = new JMenu(menuName);
   for (int i = 0; i < itemArr.length; i++) {
     menu.add(createItem(itemArr[i]));
   }
   return menu;
 }
  private void initializeGUI() {

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenuGroup = new JMenu("File");
    JMenuItem fileExit = new JMenuItem("Exit");

    fileExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            fileExit();
          }
        });

    setLayout(
        new FormLayout(
            "5px, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 1px:grow, 5px",
            "25px, 1px:grow, 1px:grow, 5px"));

    fileMenuGroup.add(fileExit);
    menuBar.add(fileMenuGroup);
    add(menuBar, CC.xywh(2, 1, 5, 1));
    pack();

    Dimension size =
        new Dimension(
            VisualizationBase.WINDOW_SIZE.width + 17, VisualizationBase.WINDOW_SIZE.height + 94);
    setSize(size);
  }
 /** Populate recent bookmarks. */
 public void populateRecentBookmarks() {
   JMenu bookmarksMenu = this.recentBookmarksMenu;
   bookmarksMenu.removeAll();
   Collection<HistoryEntry<BookmarkInfo>> historyEntries =
       BookmarksHistory.getInstance().getRecentEntries(PREFERRED_MAX_MENU_SIZE);
   for (HistoryEntry<BookmarkInfo> hentry : historyEntries) {
     BookmarkInfo binfo = hentry.getItemInfo();
     String text = binfo.getTitle();
     URL url = binfo.getUrl();
     String urlText = url.toExternalForm();
     if ((text == null) || (text.length() == 0)) {
       text = urlText;
     }
     long elapsed = System.currentTimeMillis() - hentry.getTimetstamp();
     text = text + " (" + Timing.getElapsedText(elapsed) + " ago)";
     Action action = this.actionPool.createBookmarkNavigateAction(url);
     JMenuItem menuItem = ComponentSource.menuItem(text, action);
     StringBuffer toolTipText = new StringBuffer();
     toolTipText.append("<html>");
     toolTipText.append(urlText);
     String description = binfo.getDescription();
     if ((description != null) && (description.length() != 0)) {
       toolTipText.append("<br>");
       toolTipText.append(description);
     }
     menuItem.setToolTipText(toolTipText.toString());
     bookmarksMenu.add(menuItem);
   }
 }
  public void testCreatesItemMenuWithItemsCorrectly() {
    _player.addItem(Item.BLOCKABALL);
    _player.addItem(Item.HEALVIAL);
    JMenu menu = _constructor.createItemMenu();
    assertNameAndText(menu, "Items", "Items");

    assertEquals("Number of menus was not correct", 3, menu.getItemCount());

    assertAllItemsHaveNames(menu);

    JMenuItem blockaballItemMenu = getWithName(menu, "BLOCKABALL");
    assertNotNull("Blockaball item menu was not added", blockaballItemMenu);
    assertEquals("Blockaball text was not right", "Blockaball", blockaballItemMenu.getText());
    assertNotNull("Blockaball action was not set", blockaballItemMenu.getAction());
    assertEquals(ItemAction.class, blockaballItemMenu.getAction().getClass());

    JMenuItem healVialItemMenu = getWithName(menu, "HEALVIAL");
    assertNotNull("HealVial item menu was not added", healVialItemMenu);
    assertEquals("HealVial text was not right", "Heal Vial", healVialItemMenu.getText());
    assertNotNull("HealVial action was not set", healVialItemMenu.getAction());
    assertEquals(ItemAction.class, healVialItemMenu.getAction().getClass());

    JMenuItem backItemMenu = getWithName(menu, "Back");
    assertNotNull("Back item menu was not added", backItemMenu);
    assertEquals("Back item text was not right", "Back", backItemMenu.getText());
    assertNotNull("Back action was not set", backItemMenu.getAction());
    assertEquals(BackAction.class, backItemMenu.getAction().getClass());
  }
Example #29
0
  private void addScriptCommandToOmegaT() {
    JMenu toolsMenu = Core.getMainWindow().getMainMenu().getToolsMenu();
    toolsMenu.add(new JSeparator());

    JMenuItem scriptMenu = new JMenuItem();
    Mnemonics.setLocalizedText(scriptMenu, OStrings.getString("TF_MENU_TOOLS_SCRIPTING"));
    scriptMenu.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            ScriptingWindow.this.setVisible(true);
          }
        });

    toolsMenu.add(scriptMenu);

    for (int i = 0; i < NUMBERS_OF_QUICK_SCRIPTS; i++) {
      JMenuItem menuItem = new JMenuItem();
      m_quickMenus[i] = menuItem;

      String scriptName = Preferences.getPreferenceDefault("scripts_quick_" + scriptKey(i), null);

      if (scriptName != null || "".equals(scriptName)) {
        setQuickScriptMenu(new ScriptItem(new File(m_scriptsDirectory, scriptName)), i);
      } else {
        unsetQuickScriptMenu(i);
      }

      // Since the script is run while editing a segment, the shortcut should not interfere
      // with the segment content, so we set it to a Function key.
      m_quickMenus[i].setAccelerator(KeyStroke.getKeyStroke("shift ctrl F" + (i + 1)));

      toolsMenu.add(menuItem);
    }
  }
Example #30
0
  public void setMenuBar(BeanTableFrame f) {
    final jmri.util.JmriJFrame finalF = f; // needed for anonymous ActionListener class
    JMenuBar menuBar = f.getJMenuBar();
    JMenu pathMenu = new JMenu("Paths");
    menuBar.add(pathMenu);
    JMenuItem item = new JMenuItem("Delete Paths...");
    pathMenu.add(item);
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            deletePaths(finalF);
          }
        });

    JMenu speedMenu = new JMenu("Speeds");
    item = new JMenuItem("Defaults...");
    speedMenu.add(item);
    item.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setDefaultSpeeds(finalF);
          }
        });
    menuBar.add(speedMenu);
  }