if (i != null) i.paintIcon(c, g, ir.x, ir.y);
  protected void paintMenuItem(Graphics g, JComponent c, Icon checkIcon,                               Icon arrowIcon, Color background,                               Color foreground, int defaultTextIconGap)  {    JMenuItem m = (JMenuItem) c;    Rectangle tr = new Rectangle(); // text rectangle    Rectangle ir = new Rectangle(); // icon rectangle    Rectangle vr = new Rectangle(); // view rectangle    Rectangle br = new Rectangle(); // border rectangle    Rectangle ar = new Rectangle(); // accelerator rectangle    Rectangle cr = new Rectangle(); // checkIcon rectangle    int vertAlign = m.getVerticalAlignment();    int horAlign = m.getHorizontalAlignment();    int vertTextPos = m.getVerticalTextPosition();    int horTextPos = m.getHorizontalTextPosition();    Font f = m.getFont();    g.setFont(f);    FontMetrics fm = g.getFontMetrics(f);    SwingUtilities.calculateInnerArea(m, br);    SwingUtilities.calculateInsetArea(br, m.getInsets(), vr);    paintBackground(g, m, m.getBackground());    /* MenuItems insets are equal to menuItems margin, space between text and       menuItems border. We need to paint insets region as well. */    Insets insets = m.getInsets();    br.x -= insets.left;    br.y -= insets.top;    br.width += insets.right + insets.left;    br.height += insets.top + insets.bottom;    /* Menu item is considered to be highlighted when it is selected.       It is considered to be selected if menu item is inside some menu       and is armed or if it is both armed and pressed */    if (m.getModel().isArmed()        && (m.getParent() instanceof MenuElement || m.getModel().isPressed()))      {	if (m.isContentAreaFilled())	  {	    g.setColor(selectionBackground);	    g.fillRect(br.x, br.y, br.width, br.height);	  }      }    else      {	if (m.isContentAreaFilled())	  {	    g.setColor(m.getBackground());	    g.fillRect(br.x, br.y, br.width, br.height);	  }      }    // If this menu item is a JCheckBoxMenuItem then paint check icon    if (checkIcon != null)      {	SwingUtilities.layoutCompoundLabel(m, fm, null, checkIcon, vertAlign,	                                   horAlign, vertTextPos, horTextPos,	                                   vr, cr, tr, defaultTextIconGap);	checkIcon.paintIcon(m, g, cr.x, cr.y);	// We need to calculate position of the menu text and position of	// user menu icon if there exists one relative to the check icon.	// So we need to adjust view rectangle s.t. its starting point is at	// checkIcon.width + defaultTextIconGap. 	vr.x = cr.x + cr.width + defaultTextIconGap;      }    // if this is a submenu, then paint arrow icon to indicate it.    if (arrowIcon != null && (c instanceof JMenu))      {	if (! ((JMenu) c).isTopLevelMenu())	  {	    int width = arrowIcon.getIconWidth();	    int height = arrowIcon.getIconHeight();	    arrowIcon.paintIcon(m, g, vr.width - width + defaultTextIconGap,	                        vr.y + 2);	  }      }    // paint icon    // FIXME: should paint different icon at different button state's.    // i.e disabled icon when button is disabled.. etc.    Icon i = m.getIcon();    if (i != null)      {	i.paintIcon(c, g, vr.x, vr.y);	// Adjust view rectangle, s.t text would be drawn after menu item's icon.	vr.x += i.getIconWidth() + defaultTextIconGap;      }    // paint text and user menu icon if it exists	         SwingUtilities.layoutCompoundLabel(c, fm, m.getText(), m.getIcon(),                                       vertAlign, horAlign, vertTextPos,                                       horTextPos, vr, ir, tr,                                       defaultTextIconGap);    paintText(g, m, tr, m.getText());    // paint accelerator        String acceleratorText = "";    if (m.getAccelerator() != null)      {	acceleratorText = getAcceleratorText(m.getAccelerator());	fm = g.getFontMetrics(acceleratorFont);	ar.width = fm.stringWidth(acceleratorText);	ar.x = br.width - ar.width;	vr.x = br.width - ar.width;	SwingUtilities.layoutCompoundLabel(m, fm, acceleratorText, null,	                                   vertAlign, horAlign, vertTextPos,	                                   horTextPos, vr, ir, ar,	                                   defaultTextIconGap);	paintAccelerator(g, m, ar, acceleratorText);      }  }