I want to show the elapsed time of a game i'm doing. Basically i want to call the class that keeps track of the score and with calling the class i want to start a timer that just continually runs and shows the elapsed time, this should be added.
Is there any way to do this without using System.Currenttime, i tried using that but it seems like there should be an easier way, since I don't really need a lot of precision, I just want it to start counting and close with the rest of the program.
You can use this to create a timer:
I would put 1000 in speed so that it updates every 1 second, (since the times goes my milliseconds.)
Next, I would create a label in your java program:
Then, I would do this:
That is basically how you add a timer to a label on a JFrame. For more advanced methods, these websites might help:
https://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html
http://www.javabeginner.com/java-jlabel-class-example/
How do you change label text in java after a timer ticks a second passed?
Please +1 this answer if it helped you! :)