g.setColor(color);
- Use the specified
color for subsequent
drawing commands.
g.setColor(new Color(red, green, blue));
- Create and use a color using the given amounts of
red, green,
and blue, and use the specified color for
subsequent drawing commands. Amounts are integer value between
0 and 255.
g.setColor(new Color(hexNumber));
- Create and use a color defined by the
hexNumber.
Hexadecimal numbers begin with 0x and consist of
six hex digits in the range 0..9A..F (case doesn't
matter). For example, 0xFDD018 is gold.
g.drawRect(x, y, width, height);
- Draw the outline of a rectangle starting at
x, y,
with the given width and height.
g.fillRect(x, y, width, height);
- Draw a solid rectangle or square starting at
x, y,
with the given width and height.
g.drawOval(x, y, width, height);
- Draw the outline of an ellipse or circle included in the rectangle
starting at
x, y,
with the given width and height.
g.fillOval(x, y, width, height);
- Draw a solid ellipse or circle included in the rectangle starting
at
x, y, with the
given width and height.
g.drawArc(x, y, width, height, startAngle, degrees);
- Draw an arc of a circle whose center is the center of the circle
included in the rectangle starting at
x, y,
with the given width and height.
The arc starts at startAngle (0 is the
3 o'clock position) and continues counterclockwise for the specified
number of degrees.
g.fillArc(x, y, width, height, startAngle, degrees);
- Draw a sector (wedge) of a circle whose center is the center
of the circle included in the rectangle starting at
x, y,
with the given width and height.
The sector starts at startAngle (0 is the
3 o'clock position) and continues counterclockwise for the specified
number of degrees.
g.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
- Draw the outline of a rectangle with rounded corners starting
at
x, y, with the
given width and height.
The amount of "roundedness" is given by arcWidth and arcHeight.
g.fillRoundRect(x, y, width, height, arcWidth, arcHeight);
- Draw a solid rectangle with rounded corners starting at
x, y,
with the given width and height.
The amount of "roundedness" is given by arcWidth and arcHeight.
g.drawLine(x1, y1, x2, y2);
- Draw a line from the point
(x1, y1) to
the point (x2, y2).
g.drawString("Some quoted string", x, y);
- Draws the characters inside quotes starting at the position
(x, y).
Unlike the other methods, the point (x, y) is
the bottom left corner of the first letter.
g.drawPolygon(xArray, yArray, n);
- Draws the outline of a polygon. The sequence of points is given
by the
n corresponding values in xArray and yArray.
For example, the command
g.drawPolygon(new
int[] { 250, 290, 210 },
new int[] { 210, 290, 290
}, 3);
will draw a triangle using the 3 points (250,
210), (290, 290), and (210, 290).
g.fillPolygon(xArray, yArray, n);
- Draws a solid polygon. The sequence of points is given by the
n corresponding
values in xArray and yArray.When
the edges of the polygon cross, some areas may be considered
to be
"outside" the polygon, hence not colored in.
g.drawPolyline(xArray, yArray, n);
- Draws a sequence of connected lines connecting the points given
by the
n corresponding values in xArray and yArray.
This is like drawPolygon, except that the first
and last points are not connected by a line, and the figure cannot
be filled.
|