Reloj de aguja (en lenguaje java)
import java.awt.event.*;
import java.awt.image.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
public class RelojProyecto extends JFrame{public static void main(String[] args) {
RelojProyecto app = new RelojProyecto();
app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
Reloj Cara;
publicRelojProyecto() {
super( "Reloj Proyecto" );
setVisible( true );
setResizable( false );
Container content = this.getContentPane();
content.setLayout(new BorderLayout());
Cara =new Reloj();
content.add(Cara, BorderLayout.CENTER);
this.pack();
Cara.start();
}
}
class Reloj extends JPanel {
private int horas;
private int minutos;private int segundos;
private static final int espacio = 10;
private static final float dosPi = (float)(2.0 * Math.PI);
private static final float tresPi = (float)(3.0 *Math.PI);
private static final float rad = (float)(Math.PI / 30.0);
private int tamano;
private int xCentro;
private int yCentro;
private BufferedImage muestra;
privatejavax.swing.Timer t;
public Reloj() {
this.setPreferredSize(new Dimension(300,300));
t = new javax.swing.Timer(1000,
new ActionListener() {public void actionPerformed(ActionEvent e) {
update();
}
});
}
public void update() {
this.repaint();
}
public voidstart() {
t.start();
}
public void stop() {
t.stop();
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 =(Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
int ancho = getWidth();
int alto = getHeight();
tamano =...
Regístrate para leer el documento completo.