draw Shadowed String - Java java.awt

Java examples for java.awt:Graphics2D

Description

draw Shadowed String

Demo Code

/* Copyright (c) 2001-2011, David A. Clunie DBA Pixelmed Publishing. All rights reserved. */
//package com.java2s;

import java.awt.Color;
import java.awt.Graphics2D;

public class Main {
    /**//from w ww .  j av a 2 s  . co  m
     * @param   string   the string to be drawn
     * @param   x   x position
     * @param   y   y position
     * @param   g2d   the drawing context
     */
    public static void drawShadowedString(String string, int x, int y,
            Graphics2D g2d) {
        Color holdColor = g2d.getColor();
        g2d.setColor(Color.black);
        g2d.drawString(string, x + 1, y + 1);
        g2d.setColor(holdColor);
        g2d.drawString(string, x, y);
    }
}

Related Tutorials