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("時(shí)間顯示");
??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("出錯(cuò)錯(cuò)誤,請(qǐng)重啟程序");
???}
??}??
?}?
?public static void main(String arg[])
?{
??show t=new show();
??Thread thread1=new Thread(t);
??thread1.start();??
??jf.setVisible(true);??
?}?
}