日期:2014-05-20  浏览次数:20598 次

小菜鸟的程序看不懂,请大虾过来看看!!一定给分~~~!!!!
初学java,看了本Java   2范例入门与提高,此书上18页有个水波效果的例子,费了好大的劲,把上面的代码敲了下来:   编译时出了三个警告,但也能运行.
想弄明白是怎么回事,哪位大虾赐教!!
另\:书上对这个例子没有过多的解释,很多函数我也不知道什么作用,哪位大虾能不辞劳苦给注释一下,谢谢!!

import   java.applet.Applet;//引入Applet类
import   java.awt.*;//引入图形类
public   class   splash   extends   Applet   implements   Runnable{
        int   XMAX   =   112;
      //现在的高度
        float[]   m_Height   =   new   float[XMAX];
      //移动之前的值
        float[]   m_G   =   new   float[XMAX];
      //下载因素
        float   b=1.01f;
      //   水波传播速度
        float   fWeight   =3;
        private   Thread   m_NAMI2D=null;

    //处理鼠标事件
        public   boolean   mouseDown(Event   event,int   i,int   j)
        {
                m_Height[i/4-1]+=j/2;
                m_Height[i/4]+=j;
                m_Height[i/4+1]+=j/2;
                return   false;  
        }
    //显示applet的方法
        public   void   paint(Graphics   g)
        {
                g.setColor(Color.blue);
                float   f1=3F   *   fWeight;
                float   f2=f1-2.0F;
                m_Height[0]   =   m_Height[1];
                m_Height[XMAX-1]   =   m_Height[XMAX-2];
                float   f   =   m_Height[0];
                for(int   i=1;i <XMAX-1;i++)
                {
                        float   f3   =   ((f+f2*m_Height[i]+m_Height[i+1])/f1+m_G[i])/b;
                        f=m_Height[i];
                        m_G[i]   =   f3   -   f;
                        m_Height[i]   =   f3;
                        g.clearRect((i-1)*4,(int)f3   -30,4,60);
                        g.fillRect((i-1)*4,(int)f3+30,4,60);    
                }
      }
      //此方法实现了runnable,它是线程主体。
      public   void   run()
      {
            do
                    try
                    {
                            repaint();