程序如下,请指教,谢谢。import java.awt.*;
import javax.swing.*;
import java.util.*;public class DigitalClock extends JFrame
{
WatchPanel watch = new WatchPanel();

public DigitalClock()
{
super("Digital Clock");
setSize(1024, 576);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
pane.setLayout(new GridLayout(1, 1, 15, 15));
pane.add(watch);
setContentPane(pane);
this.setVisible(true);
}

public static void main(String args[])
{
DigitalClock dc = new DigitalClock();
}
}class WatchPanel extends JPanel implements Runnable
{
Thread runner;

WatchPanel()
{
if (runner == null)
  {
  runner = new Thread(this);
runner.start();  
  }
}

public void run()
{
while (true)
{
repaint();
try
{
Thread.sleep(1000);
}
catch (InterruptedException e) {}
}


public void paintCommponent(Graphics comp)
{
Graphics2D comp2D = (Graphics2D)comp;
Font type =  new Font("Jean", Font.BOLD, 18);
comp2D.setFont(type);
comp2D.setColor(getBackground());
comp2D.fillRect(0, 0, getSize().width, getSize().height);
GregorianCalendar day = new GregorianCalendar();
String time = day.getTime().toString();
comp2D.setColor(Color.blue);
comp2D.drawString(time, 5, 24);
}
}