How to draw multiple strings in awt (java) and align them -


I need to draw different lengths in three strings or three adjacent lines. I must fit the string in a fixed width, all of which Is normal for To fit the string in the given width, we can increase the font size or reduce it.

I need lines so that there is a parallel to each other.

I have used font matrix, so here is my code

  fontmatrix metric = graphics .getFontMetrics (f); Int textWidth = metrics.stringWidth (line1); Double ratio = (double) width / (double) text; Float font size = (float) (font.getSize () * ratio); Font = font.deriveFont (FONTSIZE); Matrix = graphics.gettometmetrics (font); Graphics.drawString (line1, x, y); Y + = metrics.getHeight (); // This is the same thing for the other 2 string  

This job is only for some fonts; Some fonts have huge climbing and descent, some of them are desired - / P>

What is a way to do this?


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -