What is going on?
Each node is syntactically a method call
All of these method calls are dynamically dispatched
Most don’t actually exist in bytecode
Child closures create hierarchical relations
Child widgets are added to parent containers
SwingBuilder node names are derived from Swing classes
Remove the leading ‘J’ from a Swing class when present
SwingBuilder also supports some AWT classes like layouts
Threading and the EDT
All painting and UI operations must be done in the EDT
Anything else should be outside the EDT
Swing has SwingUtilities using Runnable
Java 6 technology adds SwingWorker
However, closures are Groovy
For code inside EDT
edt { … }
doLater { … }
For code outside EDT
doOutside { … }
Build UI on the EDT
SwingBuilder.build { … }
Convention over Configuration
Java Desktop Application Conventions are MIA
Very few official examples
No Blueprints (Like Java EE Blueprints)
We have to create our own
Following Grails Patterns
Source Files Segregated by Role
Standardize App Lifecycle (like JSR-296)
Automated Packaging (App, WebStart, Applet)
Don't Repeat Yourself
How? Use a Dynamic Language!
With Closures/Blocks
With terse property syntax
myJTextArea.text = "Fires Property Change"
With terse eventing syntax
button.actionPerformed = {println 'hi'}
With Rich Annotation Support
@Bindable String aBoundProperty
Most of this impacts the View Layer
See JavaOne 2008 TS-5098 - Building Rich
Applications with Groovy's SwingBuilder
Built-in Testing
Griffon has built in support for testing
create-mvc script creates a test file in
test/integration
Uses GroovyTestCase
See JavaOne 2008 TS-5101 – Boosting your Testing
Productivity with Groovy
Griffon doesn’t write the test for you
test-app script executes the tests for you
Bootstraps the application for you
Everything up to instantiating MVC Groups
Testing Plugins
Sometimes apps need more involved testing
fest
Fluent interface for functional swing testing
easyb
Behavioral Driven Development
code-coverage – Cobertura
Line Coverage Metrics
jdepend
Code quality metrics
codenarc
Static code analysis
Automate Tasks
command line interface
Scripts and events
plugins
builders: SwingX, JIDE, Flamingo, Trident , CSS,
JavaFX and more
miscellaneous: installer (IzPack, RPM, OSX app
bundles), Splash, Wizard, Scala