Java examples for 2D Graphics:Rectangle
Calls g.fillRect(left, top, width, height) after setting the color appropriately.
//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); } }