31
2007
A First Look at GroovySWT
I’ve been working on my little app to Sync Outlook to Remember The Milk and having a great time learning GroovySWT along the way. GroovySWT offers a SwtBuilder and JFaceBuilder (simple DSL) for putting together SWT/JFace applications. Now I’m a huge fan of both SWT and JFace, so I was very keen to see what GroovySWT could let me do from straight groovy code.
It’s very early days for the GUI, but I’ve thrown together some scratchy ideas using the Tango Icon Library to get a basic interface underway.
I still think the ideal way to build GUIs is with a tool. Even with the sensational DSLs that SwingBuilder and SwtBuilder give you, nothing beats dragging and dropping stuff around (personal fave is SWT Designer, which is unbelievably good – FD: I managed to get a free copy from the early days).
But if your GUI is very simple (like the one shown above), it really does seems a shame not to be able to throw something together really quickly using straight groovy, and GroovySWT gives you that in spades. How about a little Preferences dialog for your app which automatically persists user entries to a .properties file?
preferenceDialog() {
preferencePage( title:"Proxy Settings", filename:"syncthemilk.properties" ) {
booleanFieldEditor( propertyName:"proxyEnabled", title:"Enable Proxy" )
stringFieldEditor( propertyName:"proxyHost", title:"Proxy Host" )
integerFieldEditor( propertyName:"proxyPort", title:"Proxy Port" )
}
preferencePage( title:"RTM Settings", filename:"syncthemilk.properties" ) {
stringFieldEditor( propertyName:"rtmToken", title:"RTM Token" )
}
}
I’ve found a few little bugs in the current groovy-swt source which I’ll bundle up in a patch and submit once I have the full GUI for my app done. That should let me exercise a good part of the library.
The only major shortcoming I’ve found so far is there is virtually no documentation. There are, however, a ton of good examples that demonstrate many of the cool and interesting parts of the library (including tray integration, properties dialogs, wizards, and more).
I’ll update the Groovy wiki with some new info once I’ve had a chance to get my own GUI done.
Huge props to Christiaan ten Klooster for all the fantastic work he has put into GroovySWT. Really a first class effort.
9 Comments + Add Comment
Leave a comment
Glen Smith
Archives
- January 2012
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
- April 2011
- March 2011
- January 2011
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- April 2005
- March 2005
- February 2005
- January 2005
- December 2004
- November 2004
- October 2004
- September 2004
- August 2004
- July 2004
- June 2004
- May 2004
- March 2004
- February 2004
- January 2004
- December 2003
- November 2003
- October 2003
- September 2003

An article by Glen





Hi,
It’s my first time to hear about swt & jface. May I know your preferences why not swing?
Hi James, that actually giant religious war that everyone has pretty much settled their place on one way or the other. Older blog entry here.
For me it’s just about a much simpler API and genuine native components on every platform (both look and functionality). Both are just a matter of developer preference.
I’d agree that I’d prefer to use a tool to build the GUI – it can save so much time and makes modifications much easier. The option of the Groovy builders is fantastic though.
I worked on a significant RCP and we used the Visual Editor successfully (but it was a *little* flakey). Unfortunately this project seems to be abandoned
For pure Swing development (I’m a big fan on just having one binary for all platforms) NetBeans has a good GUI builder (formerly known as Matisse).
I haven’t done anything serious with NetBeans yet, but I want to try using it for building the GUI components and I’ll probably stay with eclipse for the rest of the application.
Comparison between Visual Editor and Matisse
I’m great to see this. I’m a beginner to groovy and swt, i guest “groovyswt” will save me a lot of time to build a gui app.
But it seems that I need to install maven first to make the groovyswt samples ran, is there a standalone package to run the samples?
Hi. I just imported the project into Eclipse, and grabbed the few jars I needed from my Eclipse plugins directory. Happy to send you my .classpath file if it helps?
I’ve been learning Maven lately, so I’ll try and see what’s going on with the pom when I get a few minutes.
hi Glen, it certainly helps if I got the .classpath file from you, thanks!
my email address is [flyisland AT gmail DOT com].
Hi Glen,
Looking at fisheye http://svn.groovy.codehaus.org/browse/groovy/trunk/groovy/modules
It seems the last update to GroovySWT was back in the Aug 2006
http://docs.codehaus.org/display/GROOVY/GroovySWT
Was last updated in Nov 2006
Did you patch and submit your changes?
If so, where can I find it? or do you have a patched version lying around…?
I would very much like to use the latest GroovySWT and perhaps enhance it… for use with Eclipse 3.3x
Please advice me!
Kristian
Kristian, I never did submit any patches… but I think all I updated was the test cases anyway. Will have a hunt around and get back to you.
Hello Glen,
I’m trying to do a project with Groovy and SWT with Eclipse. But I don’t how to deal with .so files. Could you help me?