void (Component c, Graphics g, int x, int y) { Graphics2D g2 = (Graphics2D)g; UISettings.setupAntialiasing(g); Font originalFont = g.getFont(); Color originalColor = g.getColor(); g.setFont(myFont); FontMetrics fm = SwingUtilities2.getFontMetrics((JComponent)c, g); boolean isTwoChar = myStr.length() == 2; float center = getIconWidth() - fm.stringWidth(myStr) + (isTwoChar ? JBUIScale.scale(1) : 0); float textX = x + center / 2; float textY = y + SimpleColoredComponent.getTextBaseLine(fm, getIconHeight()); if (!JreHiDpiUtil.isJreHiDPI(g2)) { textX = (float)Math.floor(textX); } g.setColor(myTextColor); g2.drawString(myStr.substring(0, 1), textX, textY); if (isTwoChar) { textX += fm.charWidth(myStr.charAt(0)) - JBUIScale.scale(1); g2.drawString(myStr.substring(1), textX, textY); } g.setFont(originalFont); g.setColor(originalColor); }