// Set the desired font if different from default font.
Font font = new Font("Serif", Font.PLAIN, 12);
g2d.setFont(font);
// Draw the string such that its base line is at x, y.
g2d.drawString("aString", x, y);
// Draw the string such that the top-left corner
// is at x, y.
FontMetrics fontMetrics = g2d.getFontMetrics();
g2d.drawString(
"aString", x, y+fontMetrics.getAscent());