Here you can find the source of drawStringWithOutline(final Graphics g, final String str, int x, int y, Color fillColor, Color outlineColor)
public static void drawStringWithOutline(final Graphics g, final String str, int x, int y, Color fillColor, Color outlineColor)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Graphics; public class Main { public static void drawStringWithOutline(final Graphics g, final String str, int x, int y, Color fillColor, Color outlineColor) { g.setColor(outlineColor);//w w w. j av a 2 s . c o m for (int i = 1; i <= 1; i++) { g.drawString(str, x + i, y); g.drawString(str, x - i, y); g.drawString(str, x, y + i); g.drawString(str, x, y - i); } g.setColor(fillColor); g.drawString(str, x, y); } public static void drawStringWithOutline(final Graphics g, final String str, int x, int y) { drawStringWithOutline(g, str, x, y, Color.WHITE, Color.BLACK); } }