After looking at some code sources out there I noticed Java Swing Games usually create a class implementing Runnable, create a new Thread and set up the game loop in the run() call.

But JavaFX games seem to simply extend from Application and run the game loop in a new AnimationTimer() { ... public void handle() ... }

What gives?


Application is part of JavaFX and therefore can't be used without it and since a JavaFX app relies on the lifecycle of this class and JavaFX requires a class that extends Application, it would be impossible to not use it when creating programs with the library.

| improve this answer | |
  • \$\begingroup\$ Also, an Animation Timer automatically registers with the JavaFX pulse system (which has a dafault rate of 60fps, can be changed though) so it does the loopinp, timing and sleeping for you. \$\endgroup\$ – Ignatiamus Apr 8 '19 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.