mettre un timer java code example
Example: faire un timer en java
import java.lang.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
public class Main {
private static int heure=0,minute=0,seconde=0;
public static void main(String[] args) {
int delais=1000;
ActionListener tache_timer;
tache_timer= new ActionListener()
{
public void actionPerformed(ActionEvent e1)
{
seconde++;
if(seconde==60)
{
seconde=0;
minute++;
}
if(minute==60)
{
minute=0;
heure++;
}
System.out.println(heure+":"+minute+":"+seconde);
}
};
final Timer timer1= new Timer(delais,tache_timer);
timer1.start();
}
}