当前位置: 代码迷 >> Java相关 >> 哪个高手帮小妹``一把啊``急死了
  详细解决方案

哪个高手帮小妹``一把啊``急死了

热度:105   发布时间:2008-09-22 11:39:59.0
哪个高手帮小妹``一把啊``急死了
import java.applet.*;
import java.awt.*;
public class Bounce extends Applet implements Runnable{
    double x,y,xChange,yChange;
    double xLimit=300;
    double yLimit=300;
    Thread ball;
    public void init(){
        setBackground(Color.white);
        xChange=Math.random();
        yChange=Math.random();
        x=Math.random()*xLimit;
      y=Math.random()*yLimit;
        }
        public void start(){
            if(ball==null){
                ball=new Thread(this);
                ball.start();
                }
                }
                public void stop(){
                    if(ball!=null){
                        ball.stop();
                        ball=null;
                        }
                        }
            public void run(){

                while(true){
                    x+=xChange;
                    y+=yChange;
                    if((x>=xLimit||x<=0))xChange=-xChange;
                    if(y>=yLimit||y<=0)yChange=-yChange;
                    repaint();
                    try{
                        Thread.sleep(1);
                }catch(InterruptedException e){}
                }
                }
                public void pain(Graphics g){
                g.setColor(Color.green);
                g.fillOval((int)x,(int)y,20,20);
                    }
                    }
编译后:
Note: Bounce.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
为什么会出现这种情况啊```
搜索更多相关的解决方案: 小妹  

----------------解决方案--------------------------------------------------------
重载了一个不推荐的方法

在编译的时候后面加上 -deprecation 可以获得详细信息
----------------解决方案--------------------------------------------------------
``疑惑中``
写了 ` 这位好心哥哥```  ball.stop();
要把这个去掉 ` `但是我为何运行不出结果来 `是空白的 是什么原因呢`
----------------解决方案--------------------------------------------------------
可能使用了过期的方法,最好看一下帮助文档
----------------解决方案--------------------------------------------------------
applet要嵌到网页里面运行的
----------------解决方案--------------------------------------------------------
  相关解决方案