Esempio n. 1
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
Esempio n. 2
0
 /**
  * Returns the popup menu which is at the root of the menu system for this popup menu.
  *
  * @return the topmost grandparent <code>JPopupMenu</code>
  */
 JPopupMenu getRootPopupMenu() {
   JPopupMenu mp = this;
   while ((mp != null)
       && (mp.isPopupMenu() != true)
       && (mp.getInvoker() != null)
       && (mp.getInvoker().getParent() != null)
       && (mp.getInvoker().getParent() instanceof JPopupMenu)) {
     mp = (JPopupMenu) mp.getInvoker().getParent();
   }
   return mp;
 }
Esempio n. 3
0
 /**
  * Examines the list of menu items to determine whether <code>popup</code> is a popup menu.
  *
  * @param popup a <code>JPopupMenu</code>
  * @return true if <code>popup</code>
  */
 boolean isSubPopupMenu(JPopupMenu popup) {
   int ncomponents = this.getComponentCount();
   Component[] component = this.getComponents();
   for (int i = 0; i < ncomponents; i++) {
     Component comp = component[i];
     if (comp instanceof JMenu) {
       JMenu menu = (JMenu) comp;
       JPopupMenu subPopup = menu.getPopupMenu();
       if (subPopup == popup) return true;
       if (subPopup.isSubPopupMenu(popup)) return true;
     }
   }
   return false;
 }