void (Graphics g, JComponent comp) { UISettings.setupAntialiasing(g); JMenu jMenu = (JMenu)comp; ButtonModel buttonmodel = jMenu.getModel(); int mnemonicIndex = jMenu.getDisplayedMnemonicIndex(); Icon icon = getIcon(); Icon allowedIcon = getAllowedIcon(); checkEmptyIcon(comp); Insets insets = comp.getInsets(); resetRects(); ourViewRect.setBounds(0, 0, jMenu.getWidth(), jMenu.getHeight()); JBInsets.removeFrom(ourViewRect, insets); 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 mainColor = g.getColor(); fillBackground(g, comp, jMenu, buttonmodel, allowedIcon); 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(mainColor); 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.isEmpty()){ 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 Color disabledForeground = UIUtil.getMenuItemDisabledForeground(); if (disabledForeground != null){ g.setColor(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 (SystemInfo.isMac) { ourArrowIconRect.y += JBUIScale.scale(1); } if (buttonmodel.isArmed() || buttonmodel.isSelected()){ g.setColor(selectionForeground); } if (useCheckAndArrow()) { arrowIcon.paintIcon(comp, g, ourArrowIconRect.x, ourArrowIconRect.y); } } g.setColor(mainColor); g.setFont(font); }