*Program by Kashid
*Created on July 2005
*********************/
//Displaying Date in Swing
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Date;
public class SwingDate extends Frame
{
JLabel lbl;
Date dt;
Thread t;
public SwingDate()
{
super("Displaying Date in Swing");
lbl=new JLabel("Date:") ;
t=new Thread();
t.start();
add(lbl);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
setSize(200,100);
setVisible(true);
for(;;)
{
try
{
Thread.sleep(1000);
dt=new Date();
lbl.setText(dt.toString());
}
catch(Exception e)
{e.printStackTrace();}
}}
public static void main(String[] args) {
SwingDate si = new SwingDate();
}
}
0 comments:
Post a Comment