Adds a Color argument to the drawChars method of java.awt.Graphics. - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

Adds a Color argument to the drawChars method of java.awt.Graphics.

Demo Code


//package com.java2s;
import java.awt.*;

public class Main {
    /** Adds a Color argument to the drawChars method of
     *  java.awt.Graphics.//from w w w .  jav a  2 s . c  o m
     *
     * @param g The Graphics object.
     * @param chars An array of characters.
     * @param start The index in chars at which the
     *              string starts.
     * @param numChars Number of characters to draw
     *                 (starting at start).
     * @param x The left side of the string that gets drawn
     * @param y The <B>bottom</B> (not top) of the string.
     * @param c The color in which to draw the string.
     */

    public static void drawChars(Graphics g, char[] chars, int start,
            int numChars, int x, int y, Color c) {
        Color origColor = g.getColor();
        g.setColor(c);
        g.drawChars(chars, start, numChars, x, y);
        g.setColor(origColor);
    }

    /** Adds a Font argument to the drawChars method of
     *  java.awt.Graphics.
     *
     * @param g The Graphics object.
     * @param chars An array of characters.
     * @param start The index in chars at which the
     *              string starts.
     * @param numChars Number of characters to draw
     *                 (starting at start).
     * @param x The left side of the string that gets drawn
     * @param y The <B>bottom</B> (not top) of the string.
     * @param f The font in which to draw the string.
     */

    public static void drawChars(Graphics g, char[] chars, int start,
            int numChars, int x, int y, Font f) {
        Font origFont = g.getFont();
        g.setFont(f);
        g.drawChars(chars, start, numChars, x, y);
        g.setFont(origFont);
    }

    /** Adds Font and Color arguments to the drawChars
     *  method of java.awt.Graphics.
     *
     * @param g The Graphics object.
     * @param chars An array of characters.
     * @param start The index in chars at which the
     *              string starts.
     * @param numChars Number of characters to draw
     *                 (starting at start).
     * @param x The left side of the string that gets drawn
     * @param y The <B>bottom</B> (not top) of the string.
     * @param f The font in which to draw the string.
     * @param c The color in which to draw the string.
     */

    public static void drawChars(Graphics g, char[] chars, int start,
            int numChars, int x, int y, Font f, Color c) {
        Font origFont = g.getFont();
        g.setFont(f);
        drawChars(g, chars, start, numChars, x, y, c);
        g.setFont(origFont);
    }
}

Related Tutorials