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) {
/* Le timer */
int delais=1000;
ActionListener tache_timer;
/* Action réalisé par le 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);
}
};
/* instanciation du timer */
final Timer timer1= new Timer(delais,tache_timer);
timer1.start();
}
}
Also in Java:
- how to take binary input in java
- convert two bytes to int java
- java string regexp replace
- java random numbers in specific range
- async in fragment
- how to create a thread local variable in java
- android studio keep device awake
- java obtain list string from list object
- change the value in a hashtable java
- isnumber java
- bukkit scheduled task
- countdown timer with seekbar
- java string reverse
- android get last crash adb
- how to create a draw Rectangle in java
- javafx fill tableview with data
- java divisible by operator
- how to minimize jframe in java
- how to create an abstract class in java
- java script print date in YYYY-MM-DD HH:MM:SS format
- how to change maven java version in po,
- java function without return
- java string to uuid
- objectoutputstream exemple