Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial<noob />
17,062 Pointsquestions about the video
in order to change the text of the timer we have to bind the text of the label in this way:
<Label fx:id="time" text="${controller.timerText}"/>
is it like catching the DOM in js? that is the trick we use to keep track of the timer text?
another question i have is when and why we need to assign the type StringProperty to mTimerText, why not use a reguler String?
another question is i dont fully understand the syntax here:
setTimerText(String.format("%02d:%02d", minutes,seconds));
how the formatting is working? what %02d is doing?, what i understand is that the first placeholder is for minutes and the other for seconds.
i will highly appreiciate any help.. Steven Parker Tonnie Fanadez Steve Hunter Seth Kroger
2 Answers
<noob />
17,062 PointsSteven Parker
231,184 PointsI'm not sure what you mean by "catching the DOM" but the code shown acts as an interpolated string, where the braces following the dollar sign indicate that the code between them should be evaluated and the entire thing replaced by the result of that evaluation.
And you are right that there are two separate placeholders, one for minutes and one for seconds. The code "%02d
" means "display a decimal number that takes up two digits, and add a leading 0 if needed (to make it two digits long)."