int iconX = bounds.width - insets.right - comboIcon.getIconWidth() - 7; int iconY = insets.top + (bounds.height - comboIcon.getIconHeight()) / 2; comboIcon.paintIcon(comboBox, g, iconX, iconY);
if (! iconOnly && comboBox != null) { ListCellRenderer renderer = comboBox.getRenderer(); boolean pressed = this.getModel().isPressed(); Component comp= renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false); comp.setFont(rendererPane.getFont()); if (model.isArmed() && model.isPressed()) { if (isOpaque()) { comp.setBackground(UIManager.getColor("Button.select")); comp.setForeground(comboBox.getForeground()); } } else if (! comboBox.isEnabled()) { if (this.isOpaque()) { Color dbg = UIManager.getColor("ComboBox.disabledBackground"); comp.setBackground(dbg); Color dfg = UIManager.getColor("ComboBox.disabledForeground"); comp.setForeground(dfg); } } else { comp.setForeground(comboBox.getForeground()); comp.setBackground(comboBox.getBackground()); } int wr = w - (insets.right + iconWidth); rendererPane.paintComponent(g, comp, this, x1, y1, wr, h); }
  public void paintComponent(Graphics g)  {    super.paintComponent(g);    if (iconOnly)      {        Rectangle bounds = getBounds();        int x = (bounds.width - comboIcon.getIconWidth()) / 2;        int y = (bounds.height - comboIcon.getIconHeight()) / 2;        comboIcon.paintIcon(comboBox, g, x, y);        }    else      {        Object selected = comboBox.getModel().getSelectedItem();        if (selected == null)          selected = "";        Rectangle bounds = comboBox.getBounds();        Rectangle innerArea = SwingUtilities.calculateInnerArea(this, null);        Insets insets = comboBox.getInsets();        Rectangle renderArea = new Rectangle(innerArea.x, innerArea.y,             innerArea.width - comboIcon.getIconWidth() - 4, innerArea.height);        Component cellRenderer             = comboBox.getRenderer().getListCellRendererComponent(this.listBox,                    selected, comboBox.getSelectedIndex(), false, false);        cellRenderer.setBackground(comboBox.getBackground());        cellRenderer.setEnabled(comboBox.isEnabled());        rendererPane.paintComponent(g, cellRenderer, this, renderArea);        if (comboBox.hasFocus())          {            g.setColor(MetalLookAndFeel.getFocusColor());            g.drawRect(innerArea.x, innerArea.y - 1, innerArea.width - 1,                     innerArea.height);          }        int iconX = bounds.width - insets.right - comboIcon.getIconWidth() - 7;        int iconY = insets.top             + (bounds.height - comboIcon.getIconHeight()) / 2;         comboIcon.paintIcon(comboBox, g, iconX, iconY);                      }                  }