logo - 刷刷题
下载APP
【简答题】

[说明] 以下程序实现了在applet里移动图形文件,仔细阅读代码和相关注释,将程序补充完整。 [代码6-1] import j ava. awt. *; import j ava.awt..*; import java.applet. Applet; public class AppCIU extends Applet implements MouseMotionListener, MouseListener { Image IMG onClick=over(this) title=放大; // 声明 Image 类类型的变量 IMG onClick=over(this) title=放大 int x=70,y=60,posX=70,posY=60,dx,dy; public void init ( ) { IMG onClick=over(this) title=放大=getImage ( getCodeBase ( ) ,"mouse.gif" ); //载入影像 addMouseListener ( this ); addMouseMotionListener ( this );   } public void mousePressed ( Mouse e ) { dx=e.getX()-posX; //取得按下之点与基准点X方向的距离 dy=e.getY()-posY; //取得按下之点与基准点Y方向的距离 } public void mouseDragged ( Mouse e ) { (1) (2) if ( dx>0 && dx<120 && dy>0 && dy<60 ) //如果指针落在图形上方 { Graphics g=getGraphics ( ); (3) } } public void paint ( Graphics g ) { (4) (5) (6) } public void mouseMoved ( Mouse e ) {}; public void mouseReleased ( Mouse e ) {}; public void mouseEntered ( Mouse e ) {}; public void mouseExited ( Mouse e ) {}; public void mouseClicked ( Mouse e ) {}; }

举报
参考答案:
参考解析:
.
刷刷题刷刷变学霸