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

Java Build a JavaFX Application It's About Time Timeline Animation

Chien-wei Huang
Chien-wei Huang
2,995 Points

seconds has private access to java time duration

I have checked google and all the other parts, they say sth about my class is declaring right.... the problem is that the Duration.second doens't work here, I tried Duration.ofsecods() remain fatal.....

mTimeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1), e ->{
            mCurrentAttempt.tick();
            setTimerText(mCurrentAttempt.getmRemainingSeconds());
        }));
Chien-wei Huang
Chien-wei Huang
2,995 Points

Ok so those who encounter this problem, definitely you well cause the syntax is different now, and I fixed it by observing the libraries. Should change to

mTimeline.getKeyFrames().add(new KeyFrame(javafx.util.Duration.seconds(1), e ->{
            mCurrentAttempt.tick();
            setTimerText(mCurrentAttempt.getmRemainingSeconds());

        }));

I think you might wanna update this code as well :)

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Chien-wei Huang !

Looks like you just have a bad import of Duration make sure you choose the javafx.util version!

Thanks for pointing this out!