下面是一个Applet程序,其功能是用一组坐标点绘制一个多边形,并通过沿坐标的垂直方向移动,把它移到窗口的下半部分,然后填充它。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
程序运行结果如下:

import java.awt.*;
import java.applet.*;
/*
<applet code="ex20_3.class" width=800 height=400 >
</applet>
*/
public class ex20_3 extends Applet
int[] x = 15,50,100,160,120,190 ;
int[] y = 15,100,30, 15, 80, 50 );
public void init() (
setBackground(Color.lightGray);
public void paint(Graphics g)
int[] y2 = new int[6];
g.setColor(Color.red);
Rectangle rect = getBounds();
g.drawPolygon(x,y2,6);
for(int i=0; i<6; i++)
y2[i] = y[i] + (rect.height / 2);
g.fillPolygon(x,y,6);
ex20_3.html
<HTML>
<HEAD>
<TITLE>ex20_3</TITLE>
</HEAD>
<BODY>
<applet code="ex20 3.class" width=800 height=400 >
</applet>
</BODY>
</HTML>