Skip to content
JavaFX on steroids with Eclipse Xtend
Xtend Java
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


XtendFX is a little library making JavaFX programming in Java and Xtend a joy. Here's the typical JavaFX hello world written in Xtend :

@FXApp class HelloWorldXtend {
  override void start(Stage it) {
    title = "Hello World!"
    scene = new Scene(new StackPane => [
      children += new Button => [
        text = "Say 'Hello World'"
        onAction = [
          println("Hello World!")
    ], 300, 250)

The annotation @FXApp will make the class extend javafx.application.Application and adds a main method. The operator => lets you pass lambda expressions (the blocks in square brackets) to an expression. With a constructor this makes for a nice builder pattern. Lambdas are also handy listener for events (see onAction).

Note that besides @FXApp this is just raw JavaFX + Xtend. Let's see how XtendFX can improve on that.

FX Beans

Writing JavaFX conformant java beans is super tedious: You need to declare two fields and three methods per property! With XtendFX you can use the @FXBindable annotation and get the boilerplate eliminated automatically:

 * A login bean written in Xtend.
@FXBindable class LoginBeanXtend {
  String userName = ""
	String password

XtendFX already supports readonly and lazy properties, but it's also very easy to build your own active annotation and make it tailored to your specific needs. See active annotations.

Data Binding

The JavaFX databinding framework is awesome but programming it with Java a real pain. XtendFX let's you replace the following Java:


with this :

startButton.disableProperty  -> (anim.statusProperty != STOPPED)
pauseButton.disableProperty  -> (anim.statusProperty != RUNNING)
resumeButton.disableProperty -> (anim.statusProperty != PAUSED)
stopButton.disableProperty   -> (anim.statusProperty == STOPPED)

this only needs the correct static extension:

import static extension xtendfx.beans.binding.BindingExtensions.*

More Examples

Here's the full code the three small examples:

Btw. we are looking for creative and smart people who want to join the party!

You can’t perform that action at this time.