List of utility methods to do Draw Text
void | drawTextInCenter(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); |