Java Utililty Methods Draw Text

List of utility methods to do Draw Text

Description

The list of methods to do Draw Text are organized into topic(s).

Method

voiddrawTextInCenter(Graphics2D g2d, int x, int y, int width, int height, String predictInStepStr)
draw Text In Center
g2d.setFont(sanSerifFont);
g2d.setColor(Color.WHITE);
FontMetrics fm = g2d.getFontMetrics();
int w = fm.stringWidth(predictInStepStr);
int h = fm.getAscent();
g2d.drawString(predictInStepStr, x + width / 2 - (w / 2) + 2, y + height / 2 + (h / 4) + 2);