package graphics;

import java.awt.*;

public class Clock extends Frame {
  public Clock() {
    setSize(400, 400);
    setVisible(true);
  }

  public static void main(String args[]) {
    new Clock();
  }

  int x = 25;
  int y = 100;

  public void paint(Graphics g) {
    setForeground(Color.blue);
    setBackground(Color.red);
    Dimension d = getSize();
    FontMetrics fm =
        g.getFontMetrics();
    String ds = new java.util.Date() + "";
    int fh = fm.getHeight();
    int fw = fm.stringWidth(ds);
    int w = d.width - fw;
    int h = d.height - fh;
    g.drawString(ds, x, y);
    x++;
    y++;
    if (x > w) x = 0;
    if (y > h) y = 0;
    repaint(40);
  }
}