Dimension size = getPreferredSize(menuItem); Color foreground = g.getColor(); g.setColor(bgColor); g.drawRect(0, 0, size.width, size.height); g.setColor(foreground);
ButtonModel mod = menuItem.getModel(); if ((menuItem.isSelected() && checkIcon == null) || (mod != null && mod.isArmed()) && (menuItem.getParent() instanceof MenuElement)) { if (menuItem.isContentAreaFilled()) { g.setColor(selectionBackground); g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight()); } }
  protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor)  {    Dimension size = getPreferredSize(menuItem);    Color foreground = g.getColor();    g.setColor(bgColor);    g.drawRect(0, 0, size.width, size.height);    g.setColor(foreground);  }