A normal drawString aligns the baseline with a y argument. If you want to draw a line so that the elevation line matches y , you need to pass y + fm.getAscent() , where fm is the current FontMetrics object. See the example below.
This screenshot:

generated by the following code:
FontMetrics fm = g.getFontMetrics(); g.setColor(Color.RED); g.drawLine(10, 10, 100, 10); g.setColor(Color.BLACK); g.drawString("Hello frog", 10, 10 + fm.getAscent());
source share