//show.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.text.*;
import java.util.*;
public class show extends JFrame implements Runnable
{
static JFrame jf;
JLabel jl;
public show()
{
jf=new JFrame("时间显示");
jl=new JLabel();
jf.getContentPane().add(jl);
jf.setSize(200,100);
}
public void run()
{
while(true)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
jl.setText(sdf.format(new Date()));
try
{
Thread.sleep(1000);
}
catch(Exception e)
{
jl.setText("出错错误,请重启程序");
}
}
}
public static void main(String arg[])
{
show t=new show();
Thread thread1=new Thread(t);
thread1.start();
jf.setVisible(true);
}
}
posted on 2007-01-16 15:43
杨彩 阅读(5375)
评论(3) 编辑 收藏 所属分类:
我的Java程序