Tgod1991 Posted July 14, 2013 Share Posted July 14, 2013 Im not sure if this is correct section. How do i create a timer? For woodcutter that H0ppy made, he made a timer but i cant seem to get that one to work? I need something to do like how many total chopped and total time running etc. Some help would be great! Thanks Link to comment Share on other sites More sharing options...
Led Zeppelin Posted July 14, 2013 Share Posted July 14, 2013 Like a break timer? Link to comment Share on other sites More sharing options...
TheScrub Posted July 14, 2013 Share Posted July 14, 2013 have you created an onPaint void??? Link to comment Share on other sites More sharing options...
H0ppy Posted July 14, 2013 Share Posted July 14, 2013 (edited) Hello, Well here is the code of the Timer again: public class Timer { private long period; private long start; public Timer(long period) { this.period = period; start = System.currentTimeMillis(); } public long getElapsed() { return System.currentTimeMillis() - start; } public long getRemaining() { return period - getElapsed(); } public boolean isRunning() { return getElapsed() <= period; } public void reset() { start = System.currentTimeMillis(); } public void stop() { period = 0; } public static String format(long ms) { long sec = ms / 1000L; return String.format( "%02d:%02d:%02d", new Object[] { Long.valueOf(sec / 3600L), Long.valueOf((sec % 3600L) / 60L), Long.valueOf(sec % 60L) }); } } You create a new . java file which is called Timer Then paste this inside it. Now you can use a Timer object. If you need more info or examples then add my skype H0ppy Edited July 14, 2013 by H0ppy 2 Link to comment Share on other sites More sharing options...
Tgod1991 Posted July 19, 2013 Author Share Posted July 19, 2013 Thank you all for responses and help! Hello, Well here is the code of the Timer again: public class Timer { private long period; private long start; public Timer(long period) { this.period = period; start = System.currentTimeMillis(); } public long getElapsed() { return System.currentTimeMillis() - start; } public long getRemaining() { return period - getElapsed(); } public boolean isRunning() { return getElapsed() <= period; } public void reset() { start = System.currentTimeMillis(); } public void stop() { period = 0; } public static String format(long ms) { long sec = ms / 1000L; return String.format( "%02d:%02d:%02d", new Object[] { Long.valueOf(sec / 3600L), Long.valueOf((sec % 3600L) / 60L), Long.valueOf(sec % 60L) }); } } You create a new . java file which is called Timer Then paste this inside it.Now you can use a Timer object.If you need more info or examples then add my skype H0ppy I will do when I get some more time in coming days, thank you! Link to comment Share on other sites More sharing options...