draw Shadow Text - Java 2D Graphics

Java examples for 2D Graphics:Text

Description

draw Shadow Text

Demo Code


import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;

public class Main{
    public static void drawShadowText(Graphics2D g2, String s, int x, int y) {
        drawShadowText(g2, s, x, y, Theme.TEXT_SHADOW_COLOR, 1);
    }/*from ww  w .ja v a2 s  . c o m*/
    public static void drawShadowText(Graphics2D g2, String s, int x,
            int y, Color shadowColor, int offset) {
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        Color c = g2.getColor();
        g2.setColor(shadowColor);
        g2.drawString(s, x, y + offset);
        g2.setColor(c);
        g2.drawString(s, x, y);
    }
}

Related Tutorials