Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFx vs TornadoFx

I have started working on javafx . I wanted to know the difference between javafx and Tornadofx . How they are inter-related and different from each other.

Also when to use what.

Are there any cases where javafx is more useful/advised to use than Tornadofx or vice-versa?

like image 492
Chetna rustagi Avatar asked Jan 04 '18 05:01

Chetna rustagi


1 Answers

JavaFX is more like a toolkit (it has all the foundation needed for building a GUI). It is a feature-complete "toolkit", but it is very verbose, and the syntax contains boilerplate code, which makes it hard to maintain. That's where TornadoFX comes in. TornadoFX is like a framework based on that toolkit, which does away with all the boilerplate code, and makes the GUI building declarative, to the point that it resembles HTML.

Also, even though TornadoFX can be used from Java, it is meant to be used from Kotlin (JavaFX can be used from Kotlin also, without any issues).

TornadoFX simplifies and streamlines the GUI building process (makes the code cleaner), but it uses JavaFX "under the hood", and as such, is interoperable with JavaFX. For example, you can create a widget in pure JavaFX code, and then use it within TornadoFX, or, for example, create a whole window in TornadoFX, and then call it from JavaFX.

The main takeaway here is that TornadoFX doesn't restrict JavaFX in any way, and you can still reach low-level JavaFX stuff from TornadoFX.

Besides just the GUI builders, TornadoFX also contains useful tools like the ViewModel classes, which separate the GUI and logic (which is available, but not mandatory in any way), and some other useful tools.

Personally, I'd always use TornadoFX, because it makes the code very concise and easily-maintainable, while, at the same time, no features of JavaFX are lost.

like image 119
Aleksandar Stefanović Avatar answered Sep 25 '22 12:09

Aleksandar Stefanović