Java Draw Outline drawStringWithOutline(final Graphics g, final String str, int x, int y, Color fillColor, Color outlineColor)

Here you can find the source of drawStringWithOutline(final Graphics g, final String str, int x, int y, Color fillColor, Color outlineColor)

Description

draw String With Outline

License

Open Source License

Declaration

public static void drawStringWithOutline(final Graphics g, final String str, int x, int y, Color fillColor,
            Color outlineColor) 

Method Source Code

//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);
    }
}

Related

  1. drawOutlinedString(String s, int x, int y, Color fill, Color outline, Graphics g)
  2. drawOutlinedStringSimple(Graphics2D g, String str, int x, int y)
  3. drawOutlineText(Graphics graphics, String text, Color textColor, int x, int y, Color outlineColor, int outlineWidth)
  4. drawStringOutline(Graphics g, String s, int x, int y, Color c, Color cOutLine)