draw Rectangle - Java 2D Graphics

Java examples for 2D Graphics:Rectangle

Description

draw Rectangle

Demo Code


//package com.java2s;
import java.awt.Graphics2D;
import java.awt.Color;

import java.awt.Image;

public class Main {
    public static void drawRect(Image image, int x, int y, int width,
            int height, Color background) {
        Graphics2D g2 = (Graphics2D) image.getGraphics();
        g2.setColor(background);//from   w ww.  j av  a2  s. c o  m
        g2.fillRect(x, y, width, height);
        g2.dispose();
    }
}

Related Tutorials