eclipse编程警告:不建议使用

来源:百度知道 编辑:UC知道 时间:2024/06/13 05:10:45
import java.applet.Applet;
import java.util.*;
import java.awt.*;

public class Clock extends Applet implements Runnable
{
/**
*
*/
private static final long serialVersionUID = 4957235479618653807L;
Thread clockThread;
public void start()
{
if(clockThread==null)
{
clockThread = new Thread(this,"Clock");
clockThread.start();
}
}
public void run()
{
while(clockThread !=null)
{
repaint();
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
}
}
// @SuppressWarnings("deprecation")
public void paint(Graphics g)
{
Date now=new Date();
Font fs=new Font("宋体",Font.BOLD,28);
g.setFont(fs);
int minutes = now.getMinutes();
int seconds = now.getSeconds();
int hours = now.getHours();
g.drawString(hours+":"

不建议使用并不代表不可以用。

比如有些方法在不同环境显示出来的效果是不同的,因此他不建议使用。

如果确定你的软件使用环境不会发生以上变化那就尽管用啦。

那个date类忘了是有什么缺点了,java已经有了新的安全的类来取代他了叫Calandar 日历类,你可以查查。

最好不要用过时的类或方法