这是什么错误!!

kboy 2003-09-13 09:31:57
小弟写了一个简单的程序,出现如下错误!

Note: wumin1.java uses or overrides a deprecated API
Note: Recompile with -deprecation for details.

附:程序源码

import java.awt.*;
import java.applet.*;

class carton extends Thread
{
boolean up=false,down=false,left=false,right=false;
int position_x=200,position_y=150;
Applet applet;
Graphics g;
int sleep_time=5;
Color my_color;
public carton(Graphics a,Applet app)
{
g=a;
applet=app;
}
public void run()
{
while (true)
{
set_position();
draw_image();
try
{
sleep(sleep_time);
}
catch (InterruptedException e)
{
}
}
}
public void set_position()
{
if (up==true && position_y >1)
{
position_y --;
}
if (down==true && position_y <330)
{
position_y++;
}
if (left==true && position_x >1)
{
position_x --;
}
if (right==true && position_x <380)
{
position_x++;
}
}
public void draw_image()
{
my_color=new Color(179,179,179);
g.setColor(my_color);
g.fillRect(0,0,400,350);
my_color=new Color(100,100,100);
g.setColor(my_color);
g.fillRect(position_x,position_y,20,20);
}
public void set_direction(int direction)
{
switch(direction)
{
case(0):
up=true;
break;
case(1):
down=true;
break;
case(2):
left=true;
break;
case(3):
right=true;
break;
default:
break;
}
}
public void clear_direction(int direction)
{
switch (direction)
{
case(0):
up=false;
break;
case(1):
down=false;
break;
case(2):
left=false;
break;
case(3):
right=false;
break;
default:
break;
}
}
};

public class wumin1 extends Applet
{
carton carton_1=null;

public void start()
{
if (carton_1==null)
{
carton_1=new carton(getGraphics(),this);
carton_1.start();
}
}
public void stop()
{
carton_1.stop();
carton_1=null;
}
public boolean keyDown(Event e,int key)
{
if (key==Event.UP)
{
carton_1.set_direction(0);
}
if (key==Event.DOWN)
{
carton_1.set_direction(1);
}
if (key==Event.LEFT)
{
carton_1.set_direction(2);
}
if (key==Event.RIGHT)
{
carton_1.set_direction(3);
}
return true;
}
public boolean keyUp(Event e,int key)
{
if (key==Event.UP)
{
carton_1.clear_direction(0);
}
if (key==Event.DOWN)
{
carton_1.clear_direction(1);
}
if (key==Event.LEFT)
{
carton_1.clear_direction(2);
}
if (key==Event.RIGHT)
{
carton_1.clear_direction(3);
}
return true;
}
}
...全文
40 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jscsqb 2003-09-15
  • 打赏
  • 举报
回复
在Api函数中有些方法标记上了depreciated,这些方法已经过时,建议不再采用,当然
采用也可以编译通过。
Mars_wx 2003-09-14
  • 打赏
  • 举报
回复
这个你可以不用管他,如果你不想看到他,要么使用替换他的方法,在JDK中可以找到替换方法,要么把编译的警告等级调一下。。。调低一点。。
YuLimin 2003-09-13
  • 打赏
  • 举报
回复
用了一些不被你所用的JDK支持的一些方法
没有关系的;)
cuihao 2003-09-13
  • 打赏
  • 举报
回复
是用了过时的方法
kzjiang820218 2003-09-13
  • 打赏
  • 举报
回复
很遗憾我也不知道

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧