g.drawString(text, insets.left + 5, fm.getAscent() + 4);
Rectangle textR = new Rectangle(); text = SwingUtilities.layoutCompoundLabel(fm, text, null, SwingConstants.TOP, SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT, innerArea, new Rectangle(), textR, 0); int yAdj = (textR.height - fm.getAscent()) / 2 + 1; g.setFont(comboBox.getFont()); g.drawString(text, textR.x, textR.y + textR.height - yAdj);
  public void paintComponent(Graphics 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      {        String text = "";        Object selected = comboBox.getModel().getSelectedItem();        if (selected != null)           text = selected.toString();        Rectangle bounds = comboBox.getBounds();        Rectangle innerArea = SwingUtilities.calculateInnerArea(this, null);        if (comboBox.hasFocus())          {            g.setColor(MetalLookAndFeel.getFocusColor());            g.drawRect(innerArea.x, innerArea.y - 1, innerArea.width - 1,                     innerArea.height);          }        Insets insets = comboBox.getInsets();        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 (comboBox.isEnabled())          g.setColor(MetalLookAndFeel.getBlack());        else          g.setColor(MetalLookAndFeel.getControlDisabled());        FontMetrics fm = g.getFontMetrics(comboBox.getFont());        // FIXME: the label may need truncating with '...' and the         // alignment needs work        g.drawString(text, insets.left + 5, fm.getAscent() + 4);      }  }