Java Reference
In-Depth Information
Other methods that take similar parameters are:
fillPolygon()
fillRect()
fillRoundRect()
Methods that start with the word “draw” do not fill the interior of fig-
ures. For example:
drawRect()
drawOval()
The drawLine() method allows drawing a straight line defined by its
end points. The line attributes are those defined in the device context.
For example:
drawLine(int x1, int y1, int x2, int y2)
——————— ———————-
| |___ x/y of end point
|___________________ x/y of start point
Some vector-drawing methods of the Graphics class take arrays of co-
ordinates as a parameter. For example:
int[] xCoords = {350, 500, 500, 350};
int[] yCoords = {50, 150, 50, 150};
...
g.drawPolygon(xCoords, yCoords, 4);
———- ———- —
| | |__ number of points
| |_________ array of y coordinates
|__________________ array of x coordinates
Other methods that take similar parameters:
drawPolyline()
fillPolygon()
The drawArc() method is used to draw an arc of an ellipse, as follows:
g.drawArc( 50,
// x of start point
280,
// y of start point
150,
// width
100,
// height
45,
// start angle
180);
// arc angle
All line drawing methods use lines that are one pixel thick. This is a
great limitation of the AWT which was supposed to be fixed in later ver-
sions.
Search WWH ::




Custom Search