Example 12.6 :
import java.awt.*;
import java.applet.*;
public class polygon2 extends Applet
{
int x1[ ] = {100,10,100,200,100};
int y1[ ] = {10,100,200,100,10};
int n1 = 5;
int x2[ ] = {200,300,400,300,200};
int y2[ ] = {100,200,100,10,100};
int n2 = 5;
public void paint (Graphics g)
{
g.drawPolygon (x1, y1, n1);
g.fillPolygon (x2, y2, n2);
}
}
|
|

To demonstrate the use of draw polygon ( ) and fill polygon function. |
|
| |
|
|
|
|