Eugen Kiss edited this page Mar 2, 2016 · 38 revisions

NOTE: This project is unmaintained. Please check out TornadoFX as an up-to-date and much more comprehensive alternative. The KotlinFX's code and wiki will stay here simply for historical purposes.


KotlinFX is a layer on top of JavaFX 8 in the same vein as ScalaFX and GroovyFX are. The main benefits of KotlinFX over pure Kotlin for JavaFX 8 are UI Builders, Extension Properties for getters and setters, more natural JavaFX Binding Expressions and alternative reactive expressions.

  • UI Builders allow you to define the layout of your GUI in a hierarchical manner.
  • Extension Properties make it possible to use JavaFX's setters and getters as if they were fields.
  • KotlinFX Binding Expressions are a more natural way to define JavaFX's binding expressions.
  • Kalium is a reactive, more powerful and very convenient way to express functional dependencies between components as an alternative to binding expressions.

To give you a taste, here is ScalaFX’s frontpage example in KotlinFX:

class HelloWorld : Application() {
    override fun start(stage: Stage?) {
        Stage(stage, title="Hello World") {
            scene = Scene(width=600.0, height=450.0) {
                fill = Color.LIGHTGREEN
                root = Pane {
                    + Rectangle {
                        x = 25.0
                        y = 40.0
                        width = 100.0
                        height = 100.0
                        fill { if (hover()) Color.GREEN else Color.RED }

The result looks as follows:

The kotlinfx-demos subproject has many more examples.

Still not convinced? Then you should read Why KotlinFX! You want to kontribute? That's great! The Architecture Notes and TODO page should help you get started. In any case, feel free to contact me.

Usage Instructions

Snapshots of the library are irregularly published to the following Maven repository: http://eugenkiss.github.io/kotlinfx/repository/. That means, you can add the following to the build.gradle of your Gradle based Kotlin project to use KotlinFX:

repositories {
    maven {
        url 'http://eugenkiss.github.io/kotlinfx/repository'
dependencies {
    compile "com.eugenkiss:kotlinfx:0.2-SNAPSHOT"

The instructions for Maven are similar. You can also simply download the jar file from the URL above and use it the classical way.