【分析解答题】
下面是一个Applet程序,其功能是在绘图区域中通过鼠标的移动来绘制直线,并且有清除绘图区域按钮,用来清除已经绘制的图像。 程序运行结果如图5所示。

import jav
A、awt.*; import jav
A、applet.*; /* <applet code=ex6_7. class width=800 height=400> </applet> */ public class ex6_7 extendsApplet{ privateButton btn; private boolean bDraw,bClear; private int upX,upY,downX,downY; public void int(){ setLayout(null); bClear=false; bDraw=false; btn=newButton("clear"); btn.reshape(250, 150,70,30); add(btn); } public void paint (Graphics g){ if(bClear){ g.clearRect(0,0,getSize(). width,getSize(). height); {{U}} (1) {{/U}}; } if(bDraw){ g.drawLine({{U}} (2) {{/U}}); bDraw=false; } } public void update (Graphics g){ {{U}} (3) {{/U}}; } public boolean mouseDownEvent event, int x,int y){ downX=x; downY=y; return true; } public boolean mouseupEvent event,int X,int y){ upX = x; upY =y; {{U}} (4) {{/U}}; repaint(); return true; } public boolean actionEvent event,Object object){ if({{U}} (5) {{/U}}){ bClear=true; repaint(); } return true; } } ex6_7. html <HTML><HEAD> <TITLE>ex6_7</TITLE> </HEAD> <BODY> <appletcode=" ex6_7. class" width=800 height=400 > </applet></BODY> </HTML>