Calls g.fillRect(left, top, width, height) after setting the color appropriately. - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

Calls g.fillRect(left, top, width, height) after setting the color appropriately.

Demo Code


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

public class Main {
    /** Calls g.fillRect(left, top, width, height) after
     *  setting the color appropriately. Resets the color
     *  when done./*w w  w.j  a  v a  2  s  . c  om*/
     */

    public static void fillRect(Graphics g, int left, int top, int width,
            int height, Color c) {
        Color origColor = g.getColor();
        g.setColor(c);
        g.fillRect(left, top, width, height);
        g.setColor(origColor);
    }
}

Related Tutorials