Followup on JavaFX/Java/Groovy example - No Fluff Just Stuff

Followup on JavaFX/Java/Groovy example

Posted by: Andres Almiray on December 5, 2008

The previous post showed a small example of Java & Groovy calling JavaFX code, where Groovy used its meta-programming magic to simplify property access on JavaFX classes. Guillaume suggested adding the property interceptors to a top level interface that all JavaFX classes implement: FXObject, let's try it out shall we?
As demonstrated on the previous post, all properties in a JavaFX class have an encoded name that depends on the class's name, that encoding will also use the package name if it exists. So in this example I created another JavaFX class (Ball2) whose only difference with Ball is that the former lives in the jfxmodel package. This means that the size property should be encoded as $jfxmodel$Ball2$size. After tweaking the property interceptors to correctly handle package names this is what the updated Groovy script outputs

groovy -cp /usr/local/javafx/lib/shared/javafxrt.jar:. GBall.groovy
Bouncing 5.0 times
$jfxmodel$Ball2$size -> 10.0 class -> class jfxmodel.Ball2
10.0
20.0

Again it works!

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 »