Java Draw String drawString(Graphics2D gfx, String text, int x, int y)

Here you can find the source of drawString(Graphics2D gfx, String text, int x, int y)

Description

draw String

License

Open Source License

Declaration

public static void drawString(Graphics2D gfx, String text, int x, int y) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

public class Main {
    public static void drawString(Graphics2D gfx, String text, int x, int y) {
        Color color = gfx.getColor();
        /// Don't draw a shadow if the text is really dark.
        if (gfx.getColor().getRed() >= 33 || gfx.getColor().getBlue() >= 33 || gfx.getColor().getGreen() >= 33) {
            gfx.setColor(Color.BLACK); // Shadow
            gfx.drawString(text, x + 1, y + 1);
        }/*from   w ww.j av  a  2 s. c  om*/
        gfx.setColor(color);
        gfx.drawString(text, x, y);
    }
}

Related

  1. drawString(Graphics2D g, String s, int x, int y, int width)
  2. drawString(Graphics2D g, String string, double x, double y, Color color)
  3. drawString(Graphics2D g, String string, int x, int y)
  4. drawString(Graphics2D g, String string, int x, int y, boolean includeOutline)
  5. drawString(Graphics2D g2, String str, int x, int y, int halign, int valign)
  6. drawString(Graphics2D graphics, String text, double x, double y, boolean centerHorizontal, boolean centerVertical, Color backgroundColor)
  7. drawString(Image img, String text, Color color)
  8. drawString(String pString, Graphics2D pG, int pX, int pY, int pWidth, int pHeight, boolean pYOverflow, boolean pShrinkWords, String pJustification, boolean pDraw)
  9. drawString(String txt, int x, int y, Graphics g)