Griffon: Beyond Swing - No Fluff Just Stuff

Griffon: Beyond Swing

Posted by: Andres Almiray on December 26, 2009

If you've followed the Griffon news in the last 12 months you may be aware that Griffon is a fun and rapid desktop/rich application development framework inspired by Grails; that there are more than 40 released plugins and that polyglot programming is a pretty much a done deal (Groovy, Java, JavaFX, Scala & Clojure). Griffon was born as a means to get Swing applications off the ground quickly; a few months ago it gained the ability of mixing Swing and JavaFX components in the same application.

Just recently it went a bit further than that.

Swing is not the only toolkit that can be used with Java to create desktop applications, JavaFX is clearly one alternative (though at the time of writing this entry it still lacks a full set of controls and a healthy ecosystem of 3rd part components, but that's another story). There is also SWT, which provides better fidelity as it talks to native widgets directly as opposed to Swing. However that also imposes some restrictions (like skinning) but that has not kept the proponents of the toolkit (and Eclipse) from using it at every turn. There is also another newcomer: Pivot. Fresh from VMWare labs it quickly found a place at the Apache Incubator where it's been nurtured and awaits the moment of graduation.

What do these toolkits have to do with Griffon? Well as it turns out there is experimental (i.e, not finished yet) support for both SWT and Pivot. The following snapshot is a remake of one of groovy-swt's examples (groovy-swt provides a Groovy builder for SWT, like SwingBuilder does for Swing) as a Griffon application

Griffon SWT demo


The code is available at github. The next two snapshots are also remakes of existing examples, but these ones come from Pivot's tutorials

griffon-pivot.1

griffon-pivot.2


The code for this application is also available at github. There is an interesting side effect to adding support for SWT: native libraries and platform specific jars can be configured on any application, even by plugins. This opens the door for other plugins like JOGL, LWJGL, JMonkeyEngine and NASA's WorldWind. Granted, you can use those technologies with Griffon already (the Twittersphere application did it at JavaOne 09) but you have to manage the placement of native files and figure out the running platform for yourself (if targeting more than one that is). But now it's just a matter of following a convention and you're in business, let the framework and the plugins figure out the rest for you.

Back to SWT. No word yet on building JFace applications, RPC nor Eclipse plugins, however the sky is the limit. Contributions are very much welcome. OSGi support is also on the radar, nothing concrete just yet. On the Pivot front, almost all widgets are supported to this day, however the only supported deployment targets at the moment are desktop and webstart (applet coming soon!)

Keep on Groovying!

PD: the code for native library support is not yet final, it may change before the next release. The same applies to all plugins that depend on it.
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 »