Example of JavaFX ChangeListener in Scala

by 10/31/2012 10:42:00 AM 0 comments
I normally use IntelliJ IDEA and it's excellent Scala plugin for Scala development*. However, IntelliJ gave me a truly bogus autocomplete suggestion while adding a ChangeListener to a JavaFX Property referencing a Node:

Does Not Compile

What IntelliJ giveth:
nodeProperty.addListener(new ChangeListener[_ >: Node] {
  def changed(p1: ObservableValue[_ <: _ >: Node], p2: _ >: Node, p3: _ >: Node) {}


I had to change it to the following:
nodeProperty.addListener(new ChangeListener[Node] {
  def changed(p1: ObservableValue[_ <: Node], p2: Node, p3: Node) {}
* A footnote about developing with Scala. I normally build projects with Maven. The very excellent scala-maven-plugin, when used along-side zinc and mvnsh make for very quick code-compile cycles.

I also sometimes use SBT/ensime/Sublime Text. However, SBT and I usually agree to disagree. Fortunately, for many projects creating a dual Maven/SBT build is relatively straightforward.

Brian Schlining


Cras justo odio, dapibus ac facilisis in, egestas eget quam. Curabitur blandit tempus porttitor. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.