当前位置: 技术问答>java相关
正在编写的一段程序出错,请高手进来看看。。。
来源: 互联网 发布时间:2015-09-14
本文导语: 正在编写的一段程序出错 import java.awt.*; import java.awt.event.*; class BlockGame extends Frame { GameCanvas gameScr; Button startButton; public static boolean isPlay=false; public static int level=1,score=0; public static MyTimer timer; public...
正在编写的一段程序出错
import java.awt.*;
import java.awt.event.*;
class BlockGame extends Frame
{
GameCanvas gameScr;
Button startButton;
public static boolean isPlay=false;
public static int level=1,score=0;
public static MyTimer timer;
public BlockGame()
{
super("block game");
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
});
setSize(600,480);
setLayout(new GridLayout(1,2));
gameScr=new GameCanvas();
gameScr.addKeyListener(gameScr);
timer=new MyTimer(gameScr);
timer.setDaemon(true);
timer.start();
timer.suspend();
Panel p1=new Panel();
p1.setLayout(null);
p1.setSize(120,500);
p1.add(gameScr);
startButton=new Button("start");
startButton.setBounds(20,0,70,30);
p1.add(startButton);
add(gameScr);
add(p1);
setVisible(true);
gameScr.requestFocus();
}
public static void main(String args[])
{
System.out.println("Starting BlockGame...");
BlockGame mainFrame = new BlockGame();
//mainFrame.setSize(400, 400);
//mainFrame.setTitle("BlockGame");
//mainFrame.setVisible(true);
}
}
错误提示:
Note: d:Program FilesXinox SoftwareJCreator ProMyProjectsblockGameMyTimer.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
import java.awt.*;
import java.awt.event.*;
class BlockGame extends Frame
{
GameCanvas gameScr;
Button startButton;
public static boolean isPlay=false;
public static int level=1,score=0;
public static MyTimer timer;
public BlockGame()
{
super("block game");
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
});
setSize(600,480);
setLayout(new GridLayout(1,2));
gameScr=new GameCanvas();
gameScr.addKeyListener(gameScr);
timer=new MyTimer(gameScr);
timer.setDaemon(true);
timer.start();
timer.suspend();
Panel p1=new Panel();
p1.setLayout(null);
p1.setSize(120,500);
p1.add(gameScr);
startButton=new Button("start");
startButton.setBounds(20,0,70,30);
p1.add(startButton);
add(gameScr);
add(p1);
setVisible(true);
gameScr.requestFocus();
}
public static void main(String args[])
{
System.out.println("Starting BlockGame...");
BlockGame mainFrame = new BlockGame();
//mainFrame.setSize(400, 400);
//mainFrame.setTitle("BlockGame");
//mainFrame.setVisible(true);
}
}
错误提示:
Note: d:Program FilesXinox SoftwareJCreator ProMyProjectsblockGameMyTimer.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
|
没有说你错了,只实际使用了过时的API,编译的时候加上-deprecation就会提示你那些API已经不再推荐支持,这样的API还是不要用得好
|
查看API会告诉你应该用什么方法代替的~
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。