Followup on JavaFX/Java/Groovy example (with binding) - No Fluff Just Stuff

Followup on JavaFX/Java/Groovy example (with binding)

Posted by: Andres Almiray on December 6, 2008

Guillaume made another excellent suggestion to my last JavaFx/Groovy experiment, try to register the ObjectChangeListener by using an onChange property instead of addChangeListener(). In case you're wondering why it is because SwingBuilder supports adding event listeners by exposing the method names as property, i.e, button.actionPerformed = { ... }. It turns out it is not possible "out of the box" due to how JavaFX exposes an object's properties, even with the ExpandoMetaClass tweak. But we can tweak it again ;-)
But why leave it there, why not register change listeners directly to the container object instead of the attribute? sure we can, again tweaking FXObject's metaClass by adding a setOnChange() method
The result is exactly the same, we even piggybacked on the previous meta definitions of attribute() and onChange.

Keep on Groovying!
Andres Almiray

About Andres Almiray

Andres is a Java/Groovy developer and a Java Champion with more than 20 years of experience in software design and development. He has been involved in web and desktop application development since the early days of Java. Andres is a true believer in open source and has participated on popular projects like Groovy, Griffon, and DbUnit, as well as starting his own projects (Json-lib, EZMorph, GraphicsBuilder, JideBuilder). Founding member of the Griffon framework and Hackergarten community event. https://ch.linkedin.com/in/aalmiray

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »