[分享]一个时钟的例子
import java.awt.*;import java.util.*;
public class Mywatch
{
public static void main(String[] args)
{
Frame f = new Frame("My Watch");
Label l = new Label();
f.add(l);
f.pack();
f.setVisible(true);
while(true)
{
Calendar c = Calendar.getInstance();
l.setText(c.get(Calendar.HOUR_OF_DAY)+" : " +c.get(Calendar.MINUTE)+" : " +c.get(Calendar.SECOND));
try{Thread.sleep(1000);}
catch(Exception e){}
}
}
}