Another look at FxBuilder + Griffon - No Fluff Just Stuff

Another look at FxBuilder + Griffon

Posted by: Andres Almiray on June 10, 2009

JavaOne 2009 attendees were submitted to a bombardment of all things JavaFX (as it was expected), there are some interesting things going on with JavaFX (platform, language & tools) these days, personally I don't think it is prime time ready yet but it is getting close. It is also true that Griffon captured a fair share of attention on the Groovy community that gathered there, even some JavaFX inclined developers gazed at the framework. Particularly of interest was Dierk König's presentation: "JavaFX Programming Language + Groovy = Beauty + Productivity" where he showed a hybrid approach to making desktop applications, a JavaFX driven UI with a Groovy powered application logic, he also demonstrated the recently published NetBeans Griffon plugin (Geertjan made sure to release a beta just before JavaOne started).

The moral of the story is that Griffon and JavaFX are not competing technologies, as a matter of fact they can work together, there is no need to be asking yourself "should I go with Griffon or JavaFX for my next application?", go with both! (if that meets your application's requirements). I'd like to show you that integrating JavaFX into a Griffon application via FxBuilder is not that hard a task.

1. First you need a binary distribution of FxBuilder, which is not yet officially available. However you can download a copy of the sources [http://svn.codehaus.org/griffon/builders/fxbuilder/trunk/] and build one yourself.

2. Create a new Griffon application with griffon create-app, I went with fx as the applicaiton's name.

3. Copy FxBuilder's jar along with all JavaFX jars into fx/lib.

4. Edit griffon-app/conf/Builder.config, add a definition for FxBuilder, your file should look like this
5. Edit griffon-app/views/FxView.groovy, replace its contents with the following script
6. Run the application by typing griffon run-app, you should see a screen similar to this one



Once you click on a button it's text will be changed, this is achieved by wiring a Groovy closure, not a JavaFX function, as you can observe on the button definitions. Here is another look at the application once the buttons have been activated a few times



There you have it, there are however some caveats to using FxBuilder in its current state
  • FxBuilder relies on JavaFX SDK 1.0, work needs to be done to upgrade it to JavaFX SDK 1.2
  • FxBuilder is capable of wrapping any swing component and embed it into a JavaFx Scene but only on standalone mode, this won't work with Griffon's composite builder (yet).
  • FxBuilder does no support the full range of shape nodes nor effects found on JavaFX SDK 1.0.
There is also the matter that you are not allowed to redistribute the JavaFX runtime (read the license kids!) this means you can't create Griffon+FxBuilder applications and send them to your friends (not even publish them to the Java Store) unless your application is packaged as an applet or is webstartable.

There is chemistry between Griffon and JavaFX, sadly I cannot devote to this builder as much time as I'd like, if anyone is willing to help getting this puppy up to date with the latest JavaFX SDK please drop me a line, much appreciated :-D

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 »