public void drawParagraph(Graphics2D g, String paragraph, float width) {
    LineBreakMeasurer linebreaker = new LineBreakMeasurer(
        new AttributedString(paragraph).getIterator(), g.getFontRenderContext());

    float y = 0.0f;
    while (linebreaker.getPosition() < paragraph.length()) {
        TextLayout tl = linebreaker.nextLayout(width);

        y += tl.getAscent();
        tl.draw(g, 0, y);
        y += tl.getDescent() + tl.getLeading();

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.