Here you can find the source of drawOutlinedStringSimple(Graphics2D g, String str, int x, int y)
public static int drawOutlinedStringSimple(Graphics2D g, String str, int x, int y)
//package com.java2s; //License from project: Apache License import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.Rectangle2D; public class Main { public static int drawOutlinedStringSimple(Graphics2D g, String str, int x, int y) { Rectangle2D textArea = g.getFont().getStringBounds(str, g.getFontRenderContext()); Color textColor = g.getColor(); g.setColor(g.getBackground());/*from ww w.ja va 2 s .co m*/ g.drawString(str, x + 1, y + 1); g.drawString(str, x + 1, y - 1); g.drawString(str, x - 1, y + 1); g.drawString(str, x - 1, y - 1); g.drawString(str, x + 1, y); g.drawString(str, x - 1, y); g.drawString(str, x, y - 1); g.drawString(str, x, y + 1); g.setColor(textColor); g.drawString(str, x, y); return (int) textArea.getWidth() + 1; } }