Reloj analógico java papel

No sé si LZ quiere Java o Javascript

Te publicaré uno de Java.

Si quieres javascript, ve a Baidu y búscalo tú mismo, allí son muchos.

Importar Java .awt .

Importar Java . Applet de Java *;

La clase pública Clock extiende los implementos Runnable

{

Temporizador de subprocesos = null

Etiqueta de etiqueta <; /p>

int lastxs=50, lastys=30, lastxm=50, lastym=30, lastxh=50, lastyh=30

Public void init()

{

etiqueta = nueva etiqueta (" ");

establecer fondo (color . blanco

Agregar (etiqueta); }

Pintura pública en blanco (gráfico g)

{

int xh, yh, xm, ym, xs, ys, s, m, h, xcenter , ycenter

Fecha ahora mismo = nueva fecha();

cadena hoy = ahora mismo tolocalestring();

label.setText(hoy); /p>

s = ahora mismo. obtener segundos();

m = ahora mismo obtener minutos();

xcentro = 100;

ycentro = 80

xs =(int)(matemáticas. cos(s * 3.14f/30-3.14f/2) * 45 xcentro);

ys =(int)(math . sin(s * 3.14f/30-3.14f/2)* 45 y centro);

XM = ( int)(matemáticas. cos(m * 3.14f/30-3.14f/2)* 45 xcentro);

ym =(int)(matemáticas. pecado(m * 3.14f/30-3.14 f /2)* 45 y centro);

xh =(int)(math . cos((h * 30 m * 2)* 3.14f/180-3.14f/2)* 30 xcenter) ;

yh =(int)(math . sin((h * 30 m * 2)* 3.14f/180-3.14f/2)* 30 y centro);

g .setFont(newFont("TimesToman",Font.

simple, 14));

g.set color(color.orange);

g.fill3DRect(xcenter-50, ycenter-50, 100, 100, true); /p>

g . establecer color(color . gris oscuro);

g . g.drawString("3", xcenter 40, y center 3);

g. (" 9 ", xcenter-45, y center 3);

g . set color(color . orange

if (xs!=lastxs||ys! =lastys); )

{

g.drawLine(xcenter, ycenter, lastxs, lastys);

}

if (xm! =lastxm ||ym! =lastym)

{

g.drawLine(xcenter, ycenter-1, lastxm, lastym);

g.drawLine( xcenter- 1, ycenter, lastxm, lastym);

}

if (xh!=lastxh||yh!=lastyh)

{

g.drawLine(xcenter, ycenter-1, lastxh, último yh);

g.drawLine(xcenter-1, ycenter, lastxh, último yh);

}

g . establecer color(color . rojo);

g.drawLine(xcenter, ycenter, xs, ys);

g.drawLine(xcenter, ycenter); -1, xm, ym);

g.drawLine(xcenter-1, ycenter, xm, ym);

g.drawLine(xcenter, ycenter-1, xh, yh );

g.drawLine(xcenter-1, ycenter, xh, yh);

lastxs = xs

lastys = ys

lastxm = xm

lastym = ym

lastxh = xh

lastyh = yh

}

Público void start()

{

if(timer==null)

{

timer = nuevo hilo(este);

temporizador . start();

}

}

Sitio público no válido()

{

temporizador = null

}

Ejecución de anulación pública()

{

mientras(temporizador! =null)

{

Pruebe

{

hilo sleep(1000);

} catch. (int

excepción errónea, es decir){ }

repaint();

}

timer = null

}

actualización de vacío público (graphg)

{

Paint(g);

}

}