Assorted Griffon 0.1.0 features - No Fluff Just Stuff

Assorted Griffon 0.1.0 features

Posted by: Andres Almiray on March 19, 2009

In case you didn't catch the news last week, Griffon 0.1.0 was released! Its codebase has been aligned with Grails 1.1 (also recently released) meaning that it is now possible to create plugins (even install them globally!), other important features were added too, like MVC enhancements (create/destroy), build & application events; hopefully the release notes explain them in a sufficient manner.

But there were other features, albeit smaller, that found a new home on this release which will be described here.

Client Properties

The first is the ability to set client properties on a node using the same notation as a regular property. As you may know, Swing components have the capacity to set/retrieve any custom property you need, often paired with Look&Feel tweaks. Previous to this addition you had to write something like
Basically you had to save a reference to the component and then set the value of the custom property, now you'll be able to do the following
Neat! in case the property's name requires a non-identifier character (like a dot (.)) just surround the whole key with quotes. If you need to set several client properties on the same component you can also use the following syntax
Much better if you ask me, all properties can now be handled consistently.

Noparent node

Sometimes you'll need to tweak a component using the node syntax, i.e, for quick properties update. The sad thing of the story is that most nodes will inject the component right away in the current hierarchy (which is exactly what you'd expected in a normal scenario). For those cases where you do not want the hierarchy updated use the noparent node, here is an example using SwingxtrasBuilder
If it weren't for this new node the rssIcon label would've been added to the parent vbox instead.

KeyStrokeAction shortcut

How many times have you registered an action on a JComponent that must be triggered by a KeyStroke? I can assure you the task gets tiresome by the third or fourth time, there should be a simpler way than this
Wouldn't it be sweeter if the following were to be allowed instead?
Nice! of course keyStrokeAction will let you configure different values for condition: and actionKey: if you need others than the default ones.

Bash command auto-completion

You can take advantage of bash command auto-completion if you work on a UNIX based environment (or cygwin if you're stuck with Windows :-P). Thanks go to Ken Sipe (@kensipe) for locating and translating the original Grails script by Fernando Takai (based on a post by Ted Naleid). The script is available at this link and it should be included in future Griffon distributions.

The node features described here may eventually find their way into SwingBuilder proper, which proves that Griffon's codebase is a good testing ground for new builder features.

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 »