Java Reference
In-Depth Information
void drawLine ( int x1, int y1, int x2, int y2)
Paints a line from point (x1, y1) to point (x2, y2).
void drawRect ( int x, int y, int width, int height)
Paints a rectangle with upper left corner (x, y) and dimensions width and
height.
void drawOval ( int x, int y, int width, int height)
Paints an oval bounded by the rectangle with an upper left corner of (x, y) and
dimensions width and height.
void drawString (String str, int x, int y)
Paints the character string str at point (x, y), extending to the right.
void drawArc ( int x, int y, int width, int height, int
startAngle, int arcAngle)
Paints an arc along the oval bounded by the rectangle defined by x, y, width,
and height. The arc starts at startAngle and extends for a distance defined by
arcAngle.
void fillRect ( int x, int y, int width, int height)
Same as their draw counterparts, but filled with the current foreground color.
void fillOval ( int x, int y, int width, int height)
void fillArc ( int x, int y, int width, int height,
int startAngle, int arcAngle)
Color getColor ()
Returns this graphics context's foreground color.
void setColor (Color color)
Sets this graphics context's foreground color to the specified color.
FIGURE 2.12
Some methods of the Graphics class
as ovals, are often defined by a rectangle that encompasses
their perimeters. Figure 2.13 depicts a bounding rectangle
for an oval.
An arc can be thought of as a segment of an oval. To draw
an arc, we specify the oval of which the arc is a part and the
portion of the oval in which we're interested. The starting point
KEY CONCEPT
An arc is a segment of an oval begin-
ning at a specific start angle and
extending for a distance specified by
the arc angle.
Search WWH ::




Custom Search