draw String - Java 2D Graphics

Java examples for 2D Graphics:Text

Description

draw String

Demo Code


//package com.java2s;
import java.awt.*;

public class Main {
    public static void drawString(Graphics g, String text, int x, int y) {
        for (String line : text.split("\n")) {
            g.drawString(line, x, y += g.getFontMetrics().getHeight());
        }/*  w w  w  . ja  v  a2s.c  o m*/
    }
}

Related Tutorials