Java Draw Rectangle drawRect(Graphics g, int x, int y, int w, int h)

Here you can find the source of drawRect(Graphics g, int x, int y, int w, int h)

Description

draw Rect

License

Open Source License

Declaration

public static void drawRect(Graphics g, int x, int y, int w, int h) 

Method Source Code


//package com.java2s;
/* Mesquite source code.  Copyright 1997 and onward, W. Maddison and D. Maddison. 
    /*from w  w  w .  j  av a  2 s . c  o m*/
    
Disclaimer:  The Mesquite source code is lengthy and we are few.  There are no doubt inefficiencies and goofs in this code. 
The commenting leaves much to be desired. Please approach this source code with the spirit of helping out.
Perhaps with your help we can be more than a few, and make Mesquite better.
    
Mesquite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
Mesquite's web site is http://mesquiteproject.org
    
This source code and its compiled class files are free and modifiable under the terms of 
GNU Lesser General Public License.  (http://www.gnu.org/copyleft/lesser.html)
 */

import java.awt.*;

public class Main {
    public static void drawRect(Graphics g, int x, int y, int w, int h) {
        if (w < 0) {
            int nx = x + w;
            x = nx;
            w = -w;
        }
        if (h < 0) {
            int ny = y + h;
            y = ny;
            h = -h;
        }
        g.drawRect(x, y, w, h);
    }
}

Related

  1. drawRect(Graphics g, int left, int top, int width, int height, int lineWidth)
  2. drawRect(Graphics g, int x, int y, int w, int h)
  3. drawRect(Graphics g, Rectangle r)
  4. drawRect(Rectangle r, Graphics2D g)
  5. drawRectOrOval(Graphics2D g, boolean oval, int arc, int x, int y, int width, int height)