Class GraphicsUtil

Class GraphicsUtil

java.lang.Object
   |
   +----GraphicsUtil

Note: To see an on-line demo, see the page for GraphicsUtilDemo.html. To download the source code, see GraphicsUtil.java. For more examples, see the Core Web Programming source code archive.
public class GraphicsUtil
extends Object
A class that extends the drawXxx and fillXxx methods of java.awt.Graphics. In particular, it adds line width (pen thickness) arguments to most of the drawXxx methods, a Color argument to most of the drawXxx and fillXxx methods, and a Font argument to drawString and drawChars. Also creates drawCircle and fillCircle methods.

Rather than including the Graphics object in a call to a constructor, the methods are all static, and the Graphics is included as the first argument to each of the methods. Don't forget to include it.

For instance, here is how you would draw a 10-pixel wide blue line from (10,10) to (200, 200) and a 5-pixel thick red circle of radius 50 centered at (200, 200):

   public void paint(Graphics g) {
     ...
     GraphicsUtil.drawLine(g, 10, 10, 200, 200,
                           10, Color.blue);
     GraphicsUtil.drawCircle(g, 200, 200, 50,
                             5, Color.red);
     ...
   }
Version:
1.0 (1997)
Author:
Marty Hall (hall@apl.jhu.edu)

Constructor Index

 o GraphicsUtil()

Method Index

 o draw3DRect(Graphics, int, int, int, int, boolean, Color)
Draws a 1-pixel thick 3D rectangle in the specified location with the given color.
 o draw3DRect(Graphics, int, int, int, int, boolean, int)
Draws a 3D rectangle in the specified location with the given line thickness.
 o draw3DRect(Graphics, int, int, int, int, boolean, int, Color)
Draws a 3D rectangle in the specified location with the given line thickness and color.
 o drawArc(Graphics, int, int, int, int, int, int, Color)
Adds a Color argument to the drawArc method of java.awt.Graphics.
 o drawArc(Graphics, int, int, int, int, int, int, int)
Draws an arc with the specified pen width.
 o drawArc(Graphics, int, int, int, int, int, int, int, Color)
Draws an arc with the specified pen width and color.
 o drawChars(Graphics, char[], int, int, int, int, Color)
Adds a Color argument to the drawChars method of java.awt.Graphics.
 o drawChars(Graphics, char[], int, int, int, int, Font)
Adds a Font argument to the drawChars method of java.awt.Graphics.
 o drawChars(Graphics, char[], int, int, int, int, Font, Color)
Adds Font and Color arguments to the drawChars method of java.awt.Graphics.
 o drawCircle(Graphics, int, int, int)
Calls the drawOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r.
 o drawCircle(Graphics, int, int, int, Color)
Calls the drawOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r.
 o drawCircle(Graphics, int, int, int, int)
Draws a circle of radius r at location (x,y) with the specified line width.
 o drawCircle(Graphics, int, int, int, int, Color)
Draws a circle of radius r at location (x,y) with the specified line width and color.
 o drawLine(Graphics, int, int, int, int, Color)
Draws a 1-pixel wide line from (x1, y1) to (x2, y2) using the specified color.
 o drawLine(Graphics, int, int, int, int, int)
Draws a line from (x1, y1) to (x2, y2) using the specified pen thickness.
 o drawLine(Graphics, int, int, int, int, int, Color)
Draws a line from (x1, y1) to (x2, y2) using the specified pen thickness and color.
 o drawOval(Graphics, int, int, int, int, Color)
Draws a 1-pixel thick oval in the specified bounding rectangle with the specified color.
 o drawOval(Graphics, int, int, int, int, int)
Draws an oval in the specified bounding rectangle with the specified pen thickness.
 o drawOval(Graphics, int, int, int, int, int, Color)
Draws an oval in the specified bounding rectangle with the specified pen thickness and color.
 o drawPolygon(Graphics, int[], int[], int, Color)
Draws a polygon in the specified color.
 o drawPolygon(Graphics, Polygon, Color)
Draws a polygon in the specified color.
 o drawRect(Graphics, int, int, int, int, Color)
Draws a 1-pixel thick rectangle at the specified location with the supplied color.
 o drawRect(Graphics, int, int, int, int, int)
Draws a rectangle at the specified location with the supplied pen thickness.
 o drawRect(Graphics, int, int, int, int, int, Color)
Draws a rectangle at the specified location with the supplied pen thickness and color.
 o drawRoundRect(Graphics, int, int, int, int, int, int, Color)
Draws a 1-pixel wide rounded rectangle with the specified color.
 o drawRoundRect(Graphics, int, int, int, int, int, int, int)
Draws a rounded rectangle at the specified location with the supplied pen thickness.
 o drawRoundRect(Graphics, int, int, int, int, int, int, int, Color)
Draws a rounded rectangle at the specified location with the supplied pen thickness and color.
 o drawString(Graphics, String, int, int, Color)
Calls g.drawString(s, x, y) after setting the color to c.
 o drawString(Graphics, String, int, int, Font)
Calls g.drawString(s, x, y) after setting the font to f.
 o drawString(Graphics, String, int, int, Font, Color)
Calls g.drawString(s, x, y) after setting the font to f and the color to c.
 o fill3DRect(Graphics, int, int, int, int, boolean, Color)
Makes a solid 3D rectangle in the given color.
 o fillArc(Graphics, int, int, int, int, int, int, Color)
Adds a Color argument to the fillArc method of java.awt.Graphics.
 o fillCircle(Graphics, int, int, int)
Calls the fillOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r.
 o fillCircle(Graphics, int, int, int, Color)
Calls the fillOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r.
 o fillOval(Graphics, int, int, int, int, Color)
Calls g.fillOval(left, top, width, height) after setting the color appropriately.
 o fillPolygon(Graphics, int[], int[], int, Color)
Draws a solid polygon in the specified color.
 o fillPolygon(Graphics, Polygon, Color)
Draws a solid polygon in the specified color.
 o fillRect(Graphics, int, int, int, int, Color)
Calls g.fillRect(left, top, width, height) after setting the color appropriately.
 o fillRoundRect(Graphics, int, int, int, int, int, int, Color)
Draws a solid rounded rectangle with the specified color.

Constructors

 o GraphicsUtil
  public GraphicsUtil()

Methods

 o drawArc
  public static void drawArc(Graphics g,
                             int left,
                             int top,
                             int width,
                             int height,
                             int startAngle,
                             int deltaAngle,
                             int lineWidth)
Draws an arc with the specified pen width. Note that the rectangle specified falls in the middle of the thick line (half inside it, half outside).
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle
top - The top of the bounding rectangle
width - The width of the bounding rectangle
height - The height of the bounding rectangle
startAngle - The beginning angle in degrees. 0 is 3 o'clock, increasing counterclockwise.
deltaAngle - The sweep angle in degrees (going counterclockwise).
lineWidth - The pen width (thickness of line drawn).
 o drawArc
  public static void drawArc(Graphics g,
                             int left,
                             int top,
                             int width,
                             int height,
                             int startAngle,
                             int deltaAngle,
                             int lineWidth,
                             Color c)
Draws an arc with the specified pen width and color.
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle
top - The top of the bounding rectangle
width - The width of the bounding rectangle
height - The height of the bounding rectangle
startAngle - The beginning angle in degrees. 0 is 3 o'clock, increasing counterclockwise.
deltaAngle - The sweep angle in degrees (going counterclockwise).
lineWidth - The pen width (thickness of line drawn).
c - The Color in which to draw.
 o drawArc
  public static void drawArc(Graphics g,
                             int left,
                             int top,
                             int width,
                             int height,
                             int startAngle,
                             int deltaAngle,
                             Color c)
Adds a Color argument to the drawArc method of java.awt.Graphics.
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle
top - The top of the bounding rectangle
width - The width of the bounding rectangle
height - The height of the bounding rectangle
deltaAngle - The sweep angle in degrees (going counterclockwise).
lineWidth - The pen width (thickness of line drawn).
c - The color in which to draw the arc.
 o fillArc
  public static void fillArc(Graphics g,
                             int left,
                             int top,
                             int width,
                             int height,
                             int startAngle,
                             int deltaAngle,
                             Color c)
Adds a Color argument to the fillArc method of java.awt.Graphics.
Parameters:
g - The Graphics object.
x - The left side of the bounding rectangle
y - The top of the bounding rectangle
width - The width of the bounding rectangle
height - The height of the bounding rectangle
startAngle - The beginning angle in degrees. 0 is 3 o'clock, increasing counterclockwise.
deltaAngle - The sweep angle in degrees (going counterclockwise).
c - The color in which to draw the arc.
 o drawChars
  public static void drawChars(Graphics g,
                               char chars[],
                               int start,
                               int numChars,
                               int x,
                               int y,
                               Color c)
Adds a Color argument to the drawChars method of java.awt.Graphics.
Parameters:
g - The Graphics object.
chars - An array of characters.
start - The index in chars at which the string starts.
numChars - Number of characters to draw (starting at start).
x - The left side of the string that gets drawn
y - The bottom (not top) of the string.
c - The color in which to draw the string.
 o drawChars
  public static void drawChars(Graphics g,
                               char chars[],
                               int start,
                               int numChars,
                               int x,
                               int y,
                               Font f)
Adds a Font argument to the drawChars method of java.awt.Graphics.
Parameters:
g - The Graphics object.
chars - An array of characters.
start - The index in chars at which the string starts.
numChars - Number of characters to draw (starting at start).
x - The left side of the string that gets drawn
y - The bottom (not top) of the string.
f - The font in which to draw the string.
 o drawChars
  public static void drawChars(Graphics g,
                               char chars[],
                               int start,
                               int numChars,
                               int x,
                               int y,
                               Font f,
                               Color c)
Adds Font and Color arguments to the drawChars method of java.awt.Graphics.
Parameters:
g - The Graphics object.
chars - An array of characters.
start - The index in chars at which the string starts.
numChars - Number of characters to draw (starting at start).
x - The left side of the string that gets drawn
y - The bottom (not top) of the string.
f - The font in which to draw the string.
c - The color in which to draw the string.
 o drawCircle
  public static void drawCircle(Graphics g,
                                int x,
                                int y,
                                int r)
Calls the drawOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r.
Parameters:
g - The Graphics object.
x - The x-coordinate of the center of the circle.
y - The y-coordinate of the center of the circle.
r - The radius of the circle.
 o drawCircle
  public static void drawCircle(Graphics g,
                                int x,
                                int y,
                                int r,
                                int lineWidth)
Draws a circle of radius r at location (x,y) with the specified line width. Note that the radius r is to the center of the doughnut drawn. The outside radius will be r+lineWidth/2 (rounded down). Inside radius will be r-lineWidth/2 (rounded down).
Parameters:
g - The Graphics object.
x - The x-coordinate of the center of the circle.
y - The y-coordinate of the center of the circle.
r - The radius of the circle.
lineWidth - Pen thickness of circle drawn.
 o drawCircle
  public static void drawCircle(Graphics g,
                                int x,
                                int y,
                                int r,
                                int lineWidth,
                                Color c)
Draws a circle of radius r at location (x,y) with the specified line width and color. Note that the radius r is to the center of the doughnut drawn. The outside radius will be r+lineWidth/2 (rounded down). Inside radius will be r-lineWidth/2 (rounded down).
Parameters:
g - The Graphics object.
x - The x-coordinate of the center of the circle.
y - The y-coordinate of the center of the circle.
r - The radius of the circle.
lineWidth - Pen thickness of circle drawn.
c - The color in which to draw.
 o drawCircle
  public static void drawCircle(Graphics g,
                                int x,
                                int y,
                                int r,
                                Color c)
Calls the drawOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r. Draws in the color specified.
Parameters:
g - The Graphics object.
x - The x-coordinate of the center of the circle.
y - The y-coordinate of the center of the circle.
r - The radius of the circle.
c - The color in which to draw.
 o fillCircle
  public static void fillCircle(Graphics g,
                                int x,
                                int y,
                                int r)
Calls the fillOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r.
Parameters:
g - The Graphics object.
x - The x-coordinate of the center of the circle.
y - The y-coordinate of the center of the circle.
r - The radius of the circle.
 o fillCircle
  public static void fillCircle(Graphics g,
                                int x,
                                int y,
                                int r,
                                Color c)
Calls the fillOval method of java.awt.Graphics with a square bounding box centered at specified location with width/height of 2r. Draws in the color specified.
Parameters:
g - The Graphics object.
x - The x-coordinate of the center of the circle.
y - The y-coordinate of the center of the circle.
r - The radius of the circle.
c - The color in which to draw.
 o drawLine
  public static void drawLine(Graphics g,
                              int x1,
                              int y1,
                              int x2,
                              int y2,
                              int lineWidth)
Draws a line from (x1, y1) to (x2, y2) using the specified pen thickness.
Parameters:
g - The Graphics object.
x1 - x position of start of line.
y1 - y position of start of line.
x2 - x position of end of line.
y2 - y position of end of line.
lineWidth - Thickness of line drawn.
 o drawLine
  public static void drawLine(Graphics g,
                              int x1,
                              int y1,
                              int x2,
                              int y2,
                              int lineWidth,
                              Color c)
Draws a line from (x1, y1) to (x2, y2) using the specified pen thickness and color.
Parameters:
g - The Graphics object.
x1 - x position of start of line.
y1 - y position of start of line.
x2 - x position of end of line.
y2 - y position of end of line.
lineWidth - Thickness of line drawn.
c - The color in which to draw.
 o drawLine
  public static void drawLine(Graphics g,
                              int x1,
                              int y1,
                              int x2,
                              int y2,
                              Color c)
Draws a 1-pixel wide line from (x1, y1) to (x2, y2) using the specified color.
Parameters:
g - The Graphics object.
x1 - x position of start of line.
y1 - y position of start of line.
x2 - x position of end of line.
y2 - y position of end of line.
c - The color in which to draw.
 o drawOval
  public static void drawOval(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              int lineWidth)
Draws an oval in the specified bounding rectangle with the specified pen thickness. Note that the rectangle bounds the center (not the outside) of the oval. So the oval will really go lineWidth/2 pixels inside and outside the bounding rectangle. Specifying a width of 1 has the identical effect to g.drawOval(left, top, width, height).
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle.
top - The y-coordinate of the top of the bounding rectangle.
width - The width of the bounding rectangle.
height - The height of the bounding rectangle.
lineWidth - The pen thickness.
 o drawOval
  public static void drawOval(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              int lineWidth,
                              Color c)
Draws an oval in the specified bounding rectangle with the specified pen thickness and color. Note that the rectangle bounds the center (not the outside) of the oval. So the oval will really go lineWidth/2 pixels inside and outside the bounding rectangle. Specifying a width of 1 has the identical effect to g.drawOval(left, top, width, height).
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle.
top - The y-coordinate of the top of the bounding rectangle.
width - The width of the bounding rectangle.
height - The height of the bounding rectangle.
lineWidth - The pen thickness.
c - The color in which to draw.
 o drawOval
  public static void drawOval(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              Color c)
Draws a 1-pixel thick oval in the specified bounding rectangle with the specified color.
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle.
top - The y-coordinate of the top of the bounding rectangle.
width - The width of the bounding rectangle.
height - The height of the bounding rectangle.
c - The color in which to draw.
 o fillOval
  public static void fillOval(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              Color c)
Calls g.fillOval(left, top, width, height) after setting the color appropriately. Resets color after drawing.
Parameters:
g - The Graphics object.
left - The left side of the bounding rectangle.
top - The y-coordinate of the top of the bounding rectangle.
width - The width of the bounding rectangle.
height - The height of the bounding rectangle.
c - The color in which to draw.
 o drawPolygon
  public static void drawPolygon(Graphics g,
                                 int xPoints[],
                                 int yPoints[],
                                 int numPoints,
                                 Color c)
Draws a polygon in the specified color. Having a drawPolygon with a line width argument would be nice, but you can't just do it by drawing thick lines, since you could jagged corners. Filling in those corners takes more work, so is postponed. If someone wants to implement this and send it to me, it would be great.
 o drawPolygon
  public static void drawPolygon(Graphics g,
                                 Polygon p,
                                 Color c)
Draws a polygon in the specified color.
 o fillPolygon
  public static void fillPolygon(Graphics g,
                                 int xs[],
                                 int ys[],
                                 int numPoints,
                                 Color c)
Draws a solid polygon in the specified color.
 o fillPolygon
  public static void fillPolygon(Graphics g,
                                 Polygon p,
                                 Color c)
Draws a solid polygon in the specified color.
 o drawRect
  public static void drawRect(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              int lineWidth)
Draws a rectangle at the specified location with the supplied pen thickness. left/top are the center of the lines drawn. Ie width/height are from the center of one side to the center of the other. So the inside width/heights are really lineWidth less than the values of width and height.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
lineWidth - Pen thickness.
 o drawRect
  public static void drawRect(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              int lineWidth,
                              Color c)
Draws a rectangle at the specified location with the supplied pen thickness and color. left/top are the center of the lines drawn. Ie width/height are from the center of one side to the center of the other. So the inside width/heights are really lineWidth less than the values of width and height.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
lineWidth - Pen thickness.
c - The color in which to draw.
 o drawRect
  public static void drawRect(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              Color c)
Draws a 1-pixel thick rectangle at the specified location with the supplied color.
Parameters:
g - The Graphics object.
left - The x-coordinate of left side edge.
top - The y-coordinate of the top edge.
width - width of rectangle.
height - height of rectangle.
c - The color in which to draw.
 o fillRect
  public static void fillRect(Graphics g,
                              int left,
                              int top,
                              int width,
                              int height,
                              Color c)
Calls g.fillRect(left, top, width, height) after setting the color appropriately. Resets the color when done.
 o drawRoundRect
  public static void drawRoundRect(Graphics g,
                                   int left,
                                   int top,
                                   int width,
                                   int height,
                                   int arcWidth,
                                   int arcHeight,
                                   int lineWidth)
Draws a rounded rectangle at the specified location with the supplied pen thickness. left/top are the center of the lines drawn. Ie width/height are from the center of one side to the center of the other. So the inside width/heights are really lineWidth less than the values of width and height, and the outside width/heights are lineWidth more.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
arcWidth - Horizontal diameter of arc at corners.
arcHeight - Vertical diameter of arc at corners.
lineWidth - Pen thickness.
 o drawRoundRect
  public static void drawRoundRect(Graphics g,
                                   int left,
                                   int top,
                                   int width,
                                   int height,
                                   int arcWidth,
                                   int arcHeight,
                                   int lineWidth,
                                   Color c)
Draws a rounded rectangle at the specified location with the supplied pen thickness and color. left/top are the center of the lines drawn. Ie width/height are from the center of one side to the center of the other. So the inside width/heights are really lineWidth less than the values of width and height, and the outside width/heights are lineWidth more.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
arcWidth - Horizontal diameter of arc at corners.
arcHeight - Vertical diameter of arc at corners.
lineWidth - Pen thickness.
c - Pen color.
 o drawRoundRect
  public static void drawRoundRect(Graphics g,
                                   int left,
                                   int top,
                                   int width,
                                   int height,
                                   int arcWidth,
                                   int arcHeight,
                                   Color c)
Draws a 1-pixel wide rounded rectangle with the specified color. Same as g.drawRoundRect except for the color.
Parameters:
g - The Graphics object.
left - The x-coordinate of left edge.
top - The y-coordinate of the top edge.
width - Distance from L side to R side.
height - Distance from top side to bottom side.
arcWidth - Horizontal diameter of arc at corners.
arcHeight - Vertical diameter of arc at corners.
c - Pen color.
 o fillRoundRect
  public static void fillRoundRect(Graphics g,
                                   int left,
                                   int top,
                                   int width,
                                   int height,
                                   int arcWidth,
                                   int arcHeight,
                                   Color c)
Draws a solid rounded rectangle with the specified color. Same as g.fillRoundRect except for the color.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
arcWidth - Horizontal diameter of arc at corners.
arcHeight - Vertical diameter of arc at corners.
c - Pen color.
 o draw3DRect
  public static void draw3DRect(Graphics g,
                                int left,
                                int top,
                                int width,
                                int height,
                                boolean isRaised,
                                int lineWidth)
Draws a 3D rectangle in the specified location with the given line thickness. left/top are the center of the lines drawn. Ie width/height are from the center of one side to the center of the other. So the inside width/heights are really lineWidth less than the values of width and height; the outside width/heights are lineWidth more.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
isRaised - A boolean variable that determines if the right and bottom sides are shaded to try to make the rectangle look like it is higher than background (true) or lower (false). Works best with relatively thin lines and gray colors.
lineWidth - The pen thickness.
 o draw3DRect
  public static void draw3DRect(Graphics g,
                                int left,
                                int top,
                                int width,
                                int height,
                                boolean isRaised,
                                int lineWidth,
                                Color c)
Draws a 3D rectangle in the specified location with the given line thickness and color. left/top are the center of the lines drawn. Ie width/height are from the center of one side to the center of the other. So the inside width/heights are really lineWidth less than the values of width and height; the outside width/heights are lineWidth more.
Parameters:
g - The Graphics object.
left - Center of left side edge.
top - Center of the top edge.
width - Distance from center of L side to center of R side.
height - Distance from center of top side to center of bottom side.
isRaised - A boolean variable that determines if the right and bottom sides are shaded to try to make the rectangle look like it is higher than background (true) or lower (false). Works best with relatively thin lines and gray colors.
lineWidth - The pen thickness.
c - The pen color.
 o draw3DRect
  public static void draw3DRect(Graphics g,
                                int left,
                                int top,
                                int width,
                                int height,
                                boolean isRaised,
                                Color c)
Draws a 1-pixel thick 3D rectangle in the specified location with the given color.
Parameters:
g - The Graphics object.
left - The x-coordinate of left side edge.
top - The y-coordinate of the top edge.
width - Distance from L side to R side.
height - Distance from top side bottom side.
isRaised - A boolean variable that determines if the right and bottom sides are shaded to try to make the rectangle look like it is higher than background (true) or lower (false). Works best with gray colors.
c - The pen color.
 o fill3DRect
  public static void fill3DRect(Graphics g,
                                int left,
                                int top,
                                int width,
                                int height,
                                boolean isRaised,
                                Color c)
Makes a solid 3D rectangle in the given color.
Parameters:
g - The Graphics object.
left - The x-coordinate of left side edge.
top - The y-coordinate of the top edge.
width - Distance from L side to R side.
height - Distance from top side bottom side.
isRaised - A boolean variable that determines if the right and bottom sides are shaded to try to make the rectangle look like it is higher than background (true) or lower (false). Works best with gray colors.
c - The pen color.
 o drawString
  public static void drawString(Graphics g,
                                String s,
                                int x,
                                int y,
                                Color c)
Calls g.drawString(s, x, y) after setting the color to c. Resets the color after drawing.
Parameters:
g - The Graphics object.
s - The string to be drawn.
x - The left side of the string.
y - The bottom (not top) of the string.
c - The color in which to draw the string.
 o drawString
  public static void drawString(Graphics g,
                                String s,
                                int x,
                                int y,
                                Font f)
Calls g.drawString(s, x, y) after setting the font to f. Resets the font after drawing.
Parameters:
g - The Graphics object.
s - The string to be drawn.
x - The left side of the string
y - The bottom (not top) of the string.
f - The font in which to draw the string.
 o drawString
  public static void drawString(Graphics g,
                                String s,
                                int x,
                                int y,
                                Font f,
                                Color c)
Calls g.drawString(s, x, y) after setting the font to f and the color to c. Resets the font and color after drawing.
Parameters:
g - The Graphics object.
s - The string to be drawn.
x - The left side of the string
y - The bottom (not top) of the string.
f - The font in which to draw the string.
c - The color in which to draw the string.