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

我的程序编译有问题,请帮忙改正!
import   java.awt.*;
import   java.applet.*;
import   java.util.Date;
public   class   Clock   extends   Applet   implements   Runnable
  {
          Thread   clockThread;
          Font   font;
          public   void   init()
          {
                font   =new   Font( "TmesRoman ",Font.BOLD,48);
            }
            public   void   start()
          {
            if(clockThread==null)
            {
                clockThread=new   Thread(this, "Showtime ");
                clockThread.start();
                }
            }
            public   void   run()
            {
                  while(clockThread!=null)
                  {
                        repaint();
                        try
                        {
                              clockThread.sleep(1000);
                          }catch(InterruptedException   e)   {   }
                      }
                }
           
          public   void   paint(Graphics   g)
          {
                Date   now   =new   Date();
                g.setFont(font);
                g.setColor(Color.red);                
                g.drawString(now.getHours()+ ": "+now.getMinutes()+ ": "+now.getSeconds(),5,50);
          }
          public   void   stop()
          {
              clockThread.stop();
          }
          }    
          编译结果:
D:\xu> javac   Clock.java
Note:   Clock.java   uses   or   overrides   a   deprecated   API.
Note:   Recompile   with   -deprecation   for   details.

------解决方案--------------------
clockThread.stop();
去掉
这个方法deprecated
------解决方案--------------------