Font f = r.getFont(); g.setFont(f);
private void paintIconAndTextCentered (Graphics g, HtmlRendererImpl r) { Insets ins = r.getInsets(); Icon ic = r.getIcon(); int w = r.getWidth() - (ins.left + ins.right); int txtX = ins.left; int txtY = 0; if (ic != null && ic.getIconWidth() > 0 && ic.getIconHeight() > 0) { int iconx = w > ic.getIconWidth() ? (w / 2) - (ic.getIconWidth() / 2) : txtX; int icony = 0; ic.paintIcon(r, g, iconx, icony); txtY += ic.getIconHeight() + r.getIconTextGap(); } int txtW = r.getPreferredSize().width; txtX = txtW < r.getWidth() ? (r.getWidth() / 2) - (txtW / 2) : 0; int txtH = r.getHeight() - txtY; Font f = r.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); txtY += fm.getMaxAscent(); Color background = getBackgroundFor (r); Color foreground = ensureContrastingColor (getForegroundFor (r), background); if (r.isHtml()) { HtmlRenderer._renderHTML(r.getText(), 0, g, txtX, txtY, txtW, txtH, f, foreground, r.getRenderStyle(), true, background); } else { HtmlRenderer.renderString(r.getText(), g, txtX, txtY, txtW, txtH, r.getFont(), foreground, r.getRenderStyle(), true); } } /*
private void paintIconAndTextCentered (Graphics g, HtmlRendererImpl r) { Insets ins = r.getInsets(); Icon ic = r.getIcon(); int w = r.getWidth() - (ins.left + ins.right); int txtX = ins.left; int txtY = 0; if (ic != null && ic.getIconWidth() > 0 && ic.getIconHeight() > 0) { int iconx = w > ic.getIconWidth() ? (w / 2) - (ic.getIconWidth() / 2) : txtX; int icony = 0; ic.paintIcon(r, g, iconx, icony); txtY += ic.getIconHeight() + r.getIconTextGap(); } int txtW = r.getPreferredSize().width; txtX = txtW < r.getWidth() ? (r.getWidth() / 2) - (txtW / 2) : 0; int txtH = r.getHeight() - txtY; Font f = r.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics(f); txtY += fm.getMaxAscent(); Color background = getBackgroundFor (r); Color foreground = ensureContrastingColor (getForegroundFor (r), background); if (r.isHtml()) { HtmlRenderer._renderHTML(r.getText(), 0, g, txtX, txtY, txtW, txtH, f, foreground, r.getRenderStyle(), true, background); } else { HtmlRenderer.renderString(r.getText(), g, txtX, txtY, txtW, txtH, r.getFont(), foreground, r.getRenderStyle(), true); } } /*
Font f = r.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics();
Font f = r.getFont(); g.setFont(f); FontMetrics fm = g.getFontMetrics();