Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:52:01+00:00 2026-06-05T11:52:01+00:00

I’ve been going through some JavaFX tutorials and I have a few questions about

  • 0

I’ve been going through some JavaFX tutorials and I have a few questions about the animation system used.

    Timeline timeline = new Timeline();
    Node circle = circles;
    timeline.getKeyFrames().addAll(
                new KeyFrame(Duration.ZERO, // set start position at 0
                   new KeyValue(circle.translateXProperty(), random() * 800),
                   new KeyValue(circle.translateYProperty(), random() * 600)),

                new KeyFrame(new Duration(40000), // set end position at 40s
                   new KeyValue(circle.translateXProperty(), random() * 800),
                   new KeyValue(circle.translateYProperty(), random() * 600)));

    // play 40s of animation
    timeline.play();
    primaryStage.show();
}

What I didn’t understand were the use of the translateXProperty() functions (and Y) as well as the purpose of the random numbers in the KeyValue constructor. The way I understood the process to work was you created two KeyFrames which you interpolated between the two frame and that the KeyValue objects simply different states of your nodes, but I’m not sure that’s correct.

The tutorial I’m looking at is here: http://docs.oracle.com/javafx/2/get_started/animation.htm

I just used one circle in the code above to simplify things.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T11:52:02+00:00Added an answer on June 5, 2026 at 11:52 am

    The code moves (translates) a circle from one random location to another over a period of 40 seconds. The first keyframe specifies the starting translation co-ordinate. The second keyframe specifies the end translation co-ordinate. The JavaFX animation subsystem takes care of interpolating the translation key values across the intermediate frames behind the scenes.

    The code could have animated different properties such as scale or rotation. And it could have used absolute values rather than random ones. It just used the properties and values it did because they specify the effect the author is trying to achieve in this instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.