Rectangle bounds = getBounds(); int x = (bounds.width - comboIcon.getIconWidth()) / 2; int y = (bounds.height - comboIcon.getIconHeight()) / 2; comboIcon.paintIcon(comboBox, g, x, y);
iconX = getWidth() / 2 - iconWidth / 2; iconY = getHeight() / 2 - iconHeight / 2;
  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);                      }                  }