g2d.setComposite(fSelected
? AlphaComposite.DstOut : AlphaComposite.SrcOver);
// calculate the bottom left point to draw the text at.
Font font = g2d.getFont();
FontRenderContext renderContext = g2d.getFontRenderContext();
GlyphVector glyphVector = font.createGlyphVector(renderContext, getText());
Rectangle visualBounds = glyphVector.getVisualBounds().getBounds();
int x = getWidth() / 2 - g2d.getFontMetrics().stringWidth(getText()) / 2;
int y = getHeight() / 2 - visualBounds.height / 2 - visualBounds.y;
// draw the badge text.