public void testCreatesTheItemShopMenu() {
    ItemShop building = new ItemShop();
    building.stockItems(Item.BLOCKABALL, Item.HEALVIAL);
    JMenu menu = _constructor.createBuildingMenu(building, null);

    Assert.assertNotNull(menu);
    Assert.assertEquals(building.getName(), menu.getName());
    Assert.assertEquals(building.getName(), menu.getText());
    Assert.assertEquals(2, menu.getItemCount());
    for (int i = 0; i < menu.getItemCount(); i++) {
      JMenuItem menuItem = menu.getItem(i);
      Action action = menuItem.getAction();
      Assert.assertNotNull(action);
      Assert.assertEquals(ItemAction.class, action.getClass());

      String name = menuItem.getName();
      if (name.equals(Item.BLOCKABALL.toString())) {
        Assert.assertEquals(Item.BLOCKABALL.getWellFormattedString(), menuItem.getText());
      } else if (name.equals(Item.HEALVIAL.toString())) {
        Assert.assertEquals(Item.HEALVIAL.getWellFormattedString(), menuItem.getText());
      } else {
        Assert.fail("Name: " + name + " Text: " + menuItem.getText());
      }
    }
  }
Esempio n. 2
0
  public static JMenu[] loadMenu(String path, WindowInterface wi, Object context) {
    Element root = rootFromName(path);

    int n = root.getChildren("node").size();
    JMenu[] retval = new JMenu[n];

    int i = 0;
    ArrayList<Integer> mnemonicList = new ArrayList<Integer>();
    for (Object child : root.getChildren("node")) {
      JMenu menuItem = jMenuFromElement((Element) child, wi, context);
      retval[i++] = menuItem;
      if (((Element) child).getChild("mnemonic") != null) {
        int mnemonic = convertStringToKeyEvent(((Element) child).getChild("mnemonic").getText());
        if (mnemonicList.contains(mnemonic)) {
          log.error(
              "Menu item '"
                  + menuItem.getText()
                  + "' Mnemonic '"
                  + ((Element) child).getChild("mnemonic").getText()
                  + "' has already been assigned");
        } else {
          menuItem.setMnemonic(mnemonic);
          mnemonicList.add(mnemonic);
        }
      }
    }
    return retval;
  }
Esempio n. 3
0
 /**
  * Returns the Menu in the JMenuBar by it's name. For example:
  *
  * <p>
  *
  * <pre>
  * JMenu toolsMenu = getMenuByName("Tools");
  * </pre>
  *
  * @param name the name of the Menu.
  * @return the JMenu item with the requested name.
  */
 public JMenu getMenuByName(String name) {
   for (int i = 0; i < getMenu().getMenuCount(); i++) {
     JMenu menu = getMenu().getMenu(i);
     if (menu.getText().equals(name)) {
       return menu;
     }
   }
   return null;
 }
Esempio n. 4
0
 /** Adds a new agent application / console program demo to the specified menu. */
 private JMenuItem addAppToMenu(JMenu menu, Class<?> demoClass) {
   JMenuItem item = new JMenuItem(demoClass.getSimpleName());
   JMenu subMenu = null;
   String packageName = demoClass.getPackage().getName();
   Component[] menuComps = menu.getMenuComponents();
   int i;
   for (i = 0; i < menuComps.length; i++) {
     JMenu comp = (JMenu) menuComps[i];
     if (comp.getText().equals(packageName)) subMenu = comp;
     else if (comp.getText().compareTo(packageName) > 0) break;
   }
   if (subMenu == null) {
     subMenu = new JMenu(packageName);
     menu.add(subMenu, i);
   }
   subMenu.add(item);
   return item;
 }
 protected Dimension getPreferredMenuItemSize(
     JComponent comp, Icon checkIcon, Icon arrowIcon, int defaultTextIconGap) {
   JMenu jMenu = (JMenu) comp;
   Icon icon1 = getIcon();
   Icon icon2 = getAllowedIcon();
   String text = jMenu.getText();
   Font font = jMenu.getFont();
   FontMetrics fontmetrics = jMenu.getToolkit().getFontMetrics(font);
   resetRects();
   layoutMenuItem(
       fontmetrics,
       text,
       icon1,
       icon2,
       arrowIcon,
       jMenu.getVerticalAlignment(),
       jMenu.getHorizontalAlignment(),
       jMenu.getVerticalTextPosition(),
       jMenu.getHorizontalTextPosition(),
       ourViewRect,
       ourIconRect,
       ourTextRect,
       ourAcceleratorRect,
       ourCheckIconRect,
       ourArrowIconRect,
       text != null ? defaultTextIconGap : 0,
       defaultTextIconGap);
   ourPreferredSizeRect.setBounds(ourTextRect);
   ourPreferredSizeRect =
       SwingUtilities.computeUnion(
           ourIconRect.x,
           ourIconRect.y,
           ourIconRect.width,
           ourIconRect.height,
           ourPreferredSizeRect);
   if (useCheckAndArrow()) {
     ourPreferredSizeRect.width += myMaxGutterIconWidth;
     ourPreferredSizeRect.width += defaultTextIconGap;
     ourPreferredSizeRect.width += defaultTextIconGap;
     ourPreferredSizeRect.width += ourArrowIconRect.width;
   }
   ourPreferredSizeRect.width += 2 * defaultTextIconGap;
   Insets insets = jMenu.getInsets();
   if (insets != null) {
     ourPreferredSizeRect.width += insets.left + insets.right;
     ourPreferredSizeRect.height += insets.top + insets.bottom;
   }
   if (ourPreferredSizeRect.width % 2 == 0) {
     ourPreferredSizeRect.width++;
   }
   if (ourPreferredSizeRect.height % 2 == 0) {
     ourPreferredSizeRect.height++;
   }
   return ourPreferredSizeRect.getSize();
 }
Esempio n. 6
0
 public static void addFastKeys(JMenuBar menuBar) {
   for (Component menuComponent : menuBar.getComponents()) { // iterate over menus
     JMenu menu = (JMenu) menuComponent;
     menu.setMnemonic(menu.getText().charAt(menu.getText().indexOf('&') + 1));
     menu.setText(menu.getText().replace("&", ""));
     for (Component menuItemComponent : menu.getMenuComponents())
       if (menuItemComponent instanceof JMenuItem) { // skip separators
         JMenuItem menuItem = (JMenuItem) menuItemComponent;
         menuItem.setMnemonic(menuItem.getText().charAt(menuItem.getText().indexOf('&') + 1));
         menuItem.setText(menuItem.getText().replace("&", ""));
       }
     /*
     for (int count = 0; count < menu.getMenuComponentCount(); count++) {  //iterate over menu items
        Component menuItemComponent = menu.getMenuComponent(count);
        if (menuItemComponent instanceof JMenuItem) {   //skip separators
           JMenuItem menuItem = (JMenuItem)menuItemComponent;
           menuItem.setMnemonic(menuItem.getText().charAt(
                 menuItem.getText().indexOf('&') + 1));
           menuItem.setText(menuItem.getText().replace("&", ""));
           }
        }
     */
   }
 }
  public void testCreatesTheHealingCenterMenu() {
    Building building = new HealingCenter();
    JMenu menu = _constructor.createBuildingMenu(building, null);

    Assert.assertNotNull(menu);
    Assert.assertEquals(building.getName(), menu.getName());
    Assert.assertEquals(building.getName(), menu.getText());
    Assert.assertEquals(1, menu.getItemCount());
    for (int i = 0; i < menu.getItemCount(); i++) {
      JMenuItem menuItem = menu.getItem(i);
      Action action = menuItem.getAction();
      Assert.assertNotNull(action);
      Assert.assertEquals(HealAction.class, action.getClass());

      Assert.assertEquals("Heal", menuItem.getName());
      Assert.assertEquals("Heal", menuItem.getText());
    }
  }
 public boolean isValid(final KeyStroke keystroke, final Character keyChar) {
   if (keystroke == null) {
     return true;
   }
   final Node menuBarNode = menuBuilder.getMenuBar(menuBuilder.get(key));
   if (menuBarNode == null) {
     return true;
   }
   if (keyChar != KeyEvent.CHAR_UNDEFINED
       && (keystroke.getModifiers() & (Event.ALT_MASK | Event.CTRL_MASK | Event.META_MASK))
           == 0) {
     final String keyTypeActionString =
         ResourceController.getResourceController()
             .getProperty("key_type_action", FirstAction.EDIT_CURRENT.toString());
     FirstAction keyTypeAction = FirstAction.valueOf(keyTypeActionString);
     return FirstAction.IGNORE.equals(keyTypeAction);
   }
   if ((keystroke.getModifiers() & (Event.ALT_MASK | Event.CTRL_MASK | Event.META_MASK))
       == Event.ALT_MASK) {
     final JMenuBar menuBar = (JMenuBar) menuBarNode.getUserObject();
     final int menuCount = menuBar.getMenuCount();
     for (int i = 0; i < menuCount; i++) {
       final JMenu menu = menuBar.getMenu(i);
       final char c = (char) menu.getMnemonic();
       if (Character.toLowerCase(keystroke.getKeyCode()) == Character.toLowerCase(c)) {
         JOptionPane.showMessageDialog(
             parentComponent,
             menu.getText(),
             TextUtils.getText("used_in_menu"),
             JOptionPane.WARNING_MESSAGE);
         return false;
       }
     }
   }
   if (!checkForOverwriteShortcut(menuBarNode, keystroke)) {
     return false;
   }
   final KeyStroke derivedKS = FreeplaneMenuBar.derive(keystroke, keyChar);
   if (derivedKS == keystroke) {
     return true;
   }
   return checkForOverwriteShortcut(menuBarNode, derivedKS);
 }
 private void assertNameAndText(JMenu menu, String name, String text) {
   Assert.assertEquals("Name of the Menu should be " + name, name, menu.getName());
   Assert.assertEquals("Text of the Menu should be " + text, text, menu.getText());
 }
  public void createNewMenuBars(
      javax.swing.JMenuBar targetMenuBar,
      javax.swing.JMenuBar payrollMenuBar,
      javax.swing.JMenuBar stockMenuBar,
      javax.swing.MenuElement subElements[],
      javax.swing.JComponent popupNodes,
      javax.swing.JComponent reportsMenuBar,
      java.lang.String reportNodeTitle,
      java.lang.String utilitiesNodeTitle,
      javax.swing.ButtonGroup targetButtonGroup,
      javax.swing.ButtonGroup reportsButtonGroup) {

    final javax.swing.JMenuBar jmenubar1 = targetMenuBar;
    // subNodes = new javax.swing.tree.DefaultMutableTreeNode[subElements.length];

    // parentNode = treeNodes;

    for (int i = 0; i < subElements.length; i++) {
      // System.out.println(subElements[i]);
      if (subElements[i].getClass().getName() != "javax.swing.JPopupMenu") {

        // System.out.println("Element printing");

        javax.swing.JMenuItem abstractButton = (javax.swing.JMenuItem) subElements[i];

        //   javax.swing.tree.DefaultMutableTreeNode parentTreeNode =

        //                   System.out.println(subElements[i]);
        //   System.out.println(i);

        if (subElements[i].getClass().getName() == "javax.swing.JSeparator") {

          popupNodes.add(subElements[i].getComponent());
        }

        if (subElements[i].getClass().getName() == "javax.swing.JMenu") {

          popupMenu = new javax.swing.JMenu(abstractButton.getText());

          if (popupNodes != null) {

            if (popupMenu.getText() != "Feel") {

              popupNodes.add(popupMenu);
            }
          }

          if (abstractButton.getText() == "System") {

            if (stockMenuBar != null) {

              System.out.println("Doing system" + popupMenu.getName());

              popupMenu.setText("Control");

              //  popupReports.add(popupMenu, 4);
              //  if (stockMenuBar != null && payrollMenuBar != null) {

              stockMenuBar.add(popupMenu);
            }
          }
          if (abstractButton.getText() == "System") {

            if (payrollMenuBar != null) {

              System.out.println("Doing system" + popupMenu.getName());

              popupMenu.setText("Control");

              //  popupReports.add(popupMenu, 4);
              //  if (stockMenuBar != null && payrollMenuBar != null) {

              payrollMenuBar.add(popupMenu);
            }
          }
          if (abstractButton.getText() == "System") {

            if (reportsMenuBar != null) {

              System.out.println("Doing system" + popupMenu.getName());

              popupMenu.setText("Control");

              //  popupReports.add(popupMenu, 4);
              //  if (stockMenuBar != null && payrollMenuBar != null) {

              reportsMenuBar.add(popupMenu);
            }
          }

          if (abstractButton.getText() == "Reports") {

            if (reportsMenuBar != null) {

              popupMenu.setText(reportNodeTitle);

              reportsMenuBar.add(popupMenu);
            }
          }

          if (abstractButton.getText() == "Utility") {

            if (reportsMenuBar != null) {

              popupMenu.setText(utilitiesNodeTitle);

              reportsMenuBar.add(popupMenu);
            }
          }
        }
        if (subElements[i].getClass().getName() == "javax.swing.JMenuItem") {

          popupMenuItem = new javax.swing.JMenuItem(abstractButton.getText());

          popupMenuItem.addActionListener(
              new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {

                  System.out.println(
                      "Action Taking Place for action : [" + evt.getActionCommand() + "].");

                  getTargetMenuItem(jmenubar1.getSubElements(), evt.getActionCommand());

                  // componentActionPerformed(targetMenuBar, actionComponent.getText());

                }
              });
          //  registerActionListener(popupMenuItem, targetMenuBar);

          // popupMenuItem = abstractButton;

          popupNodes.add(popupMenuItem);

          // popupMenuItem.addActionListener(abstractButton.actionListener);

          if (!abstractButton.isEnabled()) {

            popupMenuItem.setVisible(false);
          }

          /* if (abstractButton.getText() == "Reports") {

              popupMenuItem.setText(reportNodeTitle);

              popupReports.add(popupMenuItem);

          }

          if ( abstractButton.getText() == "Utility") {

              popupMenuItem.setText(utilitiesNodeTitle);

              popupReports.add(popupMenuItem);

          }
          */
          // }

          // }
          //  System.out.println("Node : "+ subNodes[i].toString());

          //  System.out.println(tabString + abstractButton.getText());

        }

        if (subElements[i].getClass().getName() == "javax.swing.JRadioButtonMenuItem") {

          popupRadioButtonMenuItem = new javax.swing.JRadioButtonMenuItem(abstractButton.getText());

          popupRadioButtonMenuItem.addActionListener(
              new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {

                  System.out.println(
                      "Action Taking Place for action : [" + evt.getActionCommand() + "].");

                  getTargetMenuItem(jmenubar1.getSubElements(), evt.getActionCommand());

                  // componentActionPerformed(targetMenuBar, actionComponent.getText());

                }
              });
          // popupRadioButtonMenuItem = (javax.swing.JRadioButtonMenuItem)abstractButton;

          popupNodes.add(popupRadioButtonMenuItem);

          if (targetButtonGroup != null) {

            targetButtonGroup.add(popupRadioButtonMenuItem);
          }

          if (reportsButtonGroup != null) {

            reportsButtonGroup.add(popupRadioButtonMenuItem);
          }
          // popupMenuItem.addActionListener(abstractButton.actionListener);

          if (!abstractButton.isEnabled()) {

            popupMenuItem.setEnabled(false);
          }

          /* if (abstractButton.getText() == "Reports") {

              popupMenuItem.setText(reportNodeTitle);

              popupReports.add(popupMenuItem);

          }

          if ( abstractButton.getText() == "Utility") {

              popupMenuItem.setText(utilitiesNodeTitle);

              popupReports.add(popupMenuItem);

          }
          */
        }

        // }
        //  System.out.println("Node : "+ subNodes[i].toString());

        //  System.out.println(tabString + abstractButton.getText());

        // }

        if (subElements[i].getClass().getName() == "javax.swing.JCheckBoxMenuItem") {

          popupCheckBoxMenuItem = new javax.swing.JCheckBoxMenuItem(abstractButton.getText());

          popupCheckBoxMenuItem.addActionListener(
              new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {

                  System.out.println(
                      "Action Taking Place for action : [" + evt.getActionCommand() + "].");

                  getTargetMenuItem(jmenubar1.getSubElements(), evt.getActionCommand());

                  // componentActionPerformed(targetMenuBar, actionComponent.getText());

                }
              });
          // popupCheckBoxMenuItem = (javax.swing.JCheckBoxMenuItem)abstractButton;

          popupNodes.add(popupCheckBoxMenuItem);

          if (targetButtonGroup != null) {

            targetButtonGroup.add(popupCheckBoxMenuItem);
          }

          if (reportsButtonGroup != null) {

            reportsButtonGroup.add(popupCheckBoxMenuItem);
          }

          // popupMenuItem.addActionListener(abstractButton.actionListener);

          if (!abstractButton.isEnabled()) {

            popupMenuItem.setEnabled(false);
          }

          /* if (abstractButton.getText() == "Reports") {

              popupMenuItem.setText(reportNodeTitle);

              popupReports.add(popupMenuItem);

          }

          if ( abstractButton.getText() == "Utility") {

              popupMenuItem.setText(utilitiesNodeTitle);

              popupReports.add(popupMenuItem);

          }
          */
        }

        // }
        //  System.out.println("Node : "+ subNodes[i].toString());

        //  System.out.println(tabString + abstractButton.getText());
      }
      // }
      // System.out.println(abstractButton.getText());

      if (subElements[i].getSubElements().length > 0) {

        // tabString = tabString + " ";

        // parentNode = siblingNode;

        // System.out.println("See this!");

        createNewMenuBars(
            targetMenuBar,
            payrollMenuBar,
            stockMenuBar,
            subElements[i].getSubElements(),
            popupMenu,
            reportsMenuBar,
            reportNodeTitle,
            utilitiesNodeTitle,
            targetButtonGroup,
            reportsButtonGroup);

        /* if (treeNodes.isLeaf()) {


            javax.swing.tree.DefaultMutableTreeNode parentNode = (javax.swing.tree.DefaultMutableTreeNode)siblingNode.getParent();

            //                   System.out.println("Parent : ["+parentNode.getUserObject()+"]");// and Sibling : ["+siblingNode.getUserObject()+"]");

            siblingNode.removeFromParent();
            //                    parentNode.remove(siblingNode);

        }

        */
        // tabString = tabString + "\b";

      }

      // System.out.println("Element Closing");
    }

    //    parentNode = siblingNode;
    /* treeNodes = (javax.swing.tree.DefaultMutableTreeNode)treeNodes.getParent();

    if (treeNodes != null) {

        System.out.println(treeNodes.getUserObject().toString());

    }
    */

  }
  /** Create the menus holding the currently available template sets. */
  private void processTemplateFolder(File[] templates, JMenu mnuNext) {

    Vector vtTemplates = new Vector(templates.length);
    for (int i = 0; i < templates.length; i++) {
      vtTemplates.add(templates[i]);
    }

    vtTemplates = CoreUtilities.sortList(vtTemplates);

    int count = vtTemplates.size();
    for (int i = 0; i < count; i++) {
      final File nextFile = (File) vtTemplates.elementAt(i);
      String sName = nextFile.getName();
      sName = sName.replace("_", " ");

      if (nextFile.isDirectory()) {
        File subs[] = nextFile.listFiles();
        if (subs.length > 0) {
          JMenu mnuSubMenu = null;
          if (subs.length > 20) {
            mnuSubMenu = new UIScrollableMenu(sName, 0, 20);
          } else {
            mnuSubMenu = new JMenu(sName);
          }
          mnuNext.add(mnuSubMenu);
          processTemplateFolder(subs, mnuSubMenu);
        }
      } else {
        if ((sName.toLowerCase()).endsWith(".xml")) { // $NON-NLS-1$
          String sShortName = sName.substring(0, sName.length() - 4);
          sShortName = sShortName.replace("_", " ");
          JMenuItem item = new JMenuItem(sShortName);
          ActionListener oAction =
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  ProjectCompendium.APP.onTemplateImport(nextFile.getAbsolutePath());
                }
              };
          item.addActionListener(oAction);
          mnuNext.add(item);
        } else if ((sName.toLowerCase()).endsWith(".html")) { // $NON-NLS-1$
          String sShortName = sName.substring(0, sName.length() - 5);
          sShortName = sShortName.replace("_", " ");
          ImageIcon icon = UIImages.createImageIcon(UIImages.sPATH + "template-help.png");
          JMenuItem item = new JMenuItem(sShortName, icon);
          item.setToolTipText(
              LanguageProperties.getString(
                  LanguageProperties.MENUS_BUNDLE, "UIMenuTools.templatehelp"));
          ActionListener oAction =
              new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                  ExecuteControl.launch(nextFile.getAbsolutePath());
                }
              };
          //					item.addActionListener(oAction);
          if (sShortName.equals(mnuNext.getText())) {
            try {
              mnuNext.insert(item, 0);
            } catch (Exception e) {
              log.info("Exception:" + e.getLocalizedMessage());
            }
          } else {
            mnuNext.add(item);
          }
        }
      }
    }
  }
 public void paint(Graphics g, JComponent comp) {
   UIUtil.applyRenderingHints(g);
   JMenu jMenu = (JMenu) comp;
   ButtonModel buttonmodel = jMenu.getModel();
   int mnemonicIndex = jMenu.getDisplayedMnemonicIndex();
   Icon icon = getIcon();
   Icon allowedIcon = getAllowedIcon();
   Insets insets = comp.getInsets();
   resetRects();
   ourViewRect.setBounds(0, 0, jMenu.getWidth(), jMenu.getHeight());
   ourViewRect.x += insets.left;
   ourViewRect.y += insets.top;
   ourViewRect.width -= insets.right + ourViewRect.x;
   ourViewRect.height -= insets.bottom + ourViewRect.y;
   Font font = g.getFont();
   Font font1 = comp.getFont();
   g.setFont(font1);
   FontMetrics fontmetrics = g.getFontMetrics(font1);
   String s1 =
       layoutMenuItem(
           fontmetrics,
           jMenu.getText(),
           icon,
           allowedIcon,
           arrowIcon,
           jMenu.getVerticalAlignment(),
           jMenu.getHorizontalAlignment(),
           jMenu.getVerticalTextPosition(),
           jMenu.getHorizontalTextPosition(),
           ourViewRect,
           ourIconRect,
           ourTextRect,
           ourAcceleratorRect,
           ourCheckIconRect,
           ourArrowIconRect,
           jMenu.getText() != null ? defaultTextIconGap : 0,
           defaultTextIconGap);
   Color color2 = g.getColor();
   if (comp.isOpaque()) {
     g.setColor(jMenu.getBackground());
     g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight());
     if (buttonmodel.isArmed() || buttonmodel.isSelected()) {
       if (UIUtil.isUnderAquaLookAndFeel()) {
         myAquaSelectedBackgroundPainter.paintBorder(
             comp, g, 0, 0, jMenu.getWidth(), jMenu.getHeight());
       } else {
         g.setColor(selectionBackground);
         if (allowedIcon != null) {
           g.fillRect(k, 0, jMenu.getWidth() - k, jMenu.getHeight());
         } else {
           g.fillRect(0, 0, jMenu.getWidth(), jMenu.getHeight());
           g.setColor(selectionBackground);
         }
       }
     }
     g.setColor(color2);
   }
   if (allowedIcon != null) {
     if (buttonmodel.isArmed() || buttonmodel.isSelected()) {
       g.setColor(selectionForeground);
     } else {
       g.setColor(jMenu.getForeground());
     }
     if (useCheckAndArrow()) {
       allowedIcon.paintIcon(comp, g, ourCheckIconRect.x, ourCheckIconRect.y);
     }
     g.setColor(color2);
     if (menuItem.isArmed()) {
       drawIconBorder(g);
     }
   }
   if (icon != null) {
     if (!buttonmodel.isEnabled()) {
       icon = jMenu.getDisabledIcon();
     } else if (buttonmodel.isPressed() && buttonmodel.isArmed()) {
       icon = jMenu.getPressedIcon();
       if (icon == null) {
         icon = jMenu.getIcon();
       }
     }
     if (icon != null) {
       icon.paintIcon(comp, g, ourIconRect.x, ourIconRect.y);
     }
   }
   if (s1 != null && s1.length() > 0) {
     if (buttonmodel.isEnabled()) {
       if (buttonmodel.isArmed() || buttonmodel.isSelected()) {
         g.setColor(selectionForeground);
       } else {
         g.setColor(jMenu.getForeground());
       }
       BasicGraphicsUtils.drawStringUnderlineCharAt(
           g, s1, mnemonicIndex, ourTextRect.x, ourTextRect.y + fontmetrics.getAscent());
     } else {
       final Object disabledForeground = UIUtil.getMenuItemDisabledForeground();
       if (disabledForeground instanceof Color) {
         g.setColor((Color) disabledForeground);
         BasicGraphicsUtils.drawStringUnderlineCharAt(
             g, s1, mnemonicIndex, ourTextRect.x, ourTextRect.y + fontmetrics.getAscent());
       } else {
         g.setColor(jMenu.getBackground().brighter());
         BasicGraphicsUtils.drawStringUnderlineCharAt(
             g, s1, mnemonicIndex, ourTextRect.x, ourTextRect.y + fontmetrics.getAscent());
         g.setColor(jMenu.getBackground().darker());
         BasicGraphicsUtils.drawStringUnderlineCharAt(
             g,
             s1,
             mnemonicIndex,
             ourTextRect.x - 1,
             (ourTextRect.y + fontmetrics.getAscent()) - 1);
       }
     }
   }
   if (arrowIcon != null) {
     if (buttonmodel.isArmed() || buttonmodel.isSelected()) {
       g.setColor(selectionForeground);
     }
     if (useCheckAndArrow()) {
       try {
         if (SystemInfo.isMac
             && myAquaInvertedArrowIcon != null
             && (buttonmodel.isArmed() || buttonmodel.isSelected())
             && UIUtil.isUnderAquaLookAndFeel()) {
           myAquaInvertedArrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y);
         } else if (SystemInfo.isMac
             && myAquaDisabledArrowIcon != null
             && !buttonmodel.isEnabled()
             && UIUtil.isUnderAquaLookAndFeel()) {
           myAquaDisabledArrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y);
         } else arrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y);
       } catch (NullPointerException npe) {
         // GTKIconFactory$MenuArrowIcon.paintIcon since it doesn't expect to be given a null
         // instead of SynthContext
         // http://www.jetbrains.net/jira/browse/IDEADEV-22360
       }
     }
   }
   g.setColor(color2);
   g.setFont(font);
 }