JellySwing

JellySwing is a simple Jelly tag-library which can be used to create Swing user interfaces. It allows XML documents (Jelly scripts) to be used to define the layout and rendering of Swing front ends which avoids lots of mundane Java coding, using markup to define the view of your front end and allowing you to bind to Java code for the business objects and models.

This mechanism uses seperation of concerns and MVC ideas from web applications, allowing the rendering of your Swing front end to be easily transformed (since its XML) into different styles while leaving your model and business objects untouched. It also allows different views to be constructed independently of your models.

There is an example JellySwing script here

To try running the example type the following command then you should see a full Swing user interface appear with pull down menus, a splitter pane, a form, entry fields, buttons and a table. (you should run this from within the [jelly-home]/jelly-tags/swing).

maven demo:swing

This example even shows that simple actions can be coded in Jelly script too! Though typically most complex logic and models (such as TableModel, TreeModel) should be written in Java code. Then Jelly script can be used to create the view and bind in the models.

JellyRunner

JellyRunner is a simple example Swing user interface written with JellySwing. You can view the source to it here

If you invoke it via the following command you will get a small Swing UI that allows you to choose Jelly scripts to invoke, within the current JVM.

 maven jelly:runner

This makes developing Jelly scripts and JellySwing scripts in particular, much more RAD-like. You can keep JellyRunner open, edit a Jelly script and just hit the 'Run' button and the script executes instantaneously, there's no waiting for a JVM to startup.

Comparing JellySwing with Java code for Swing

There's a simple demo written by Otto von Wachter which demonstrates how Jelly can be used for templating HTML.

The demo was orignally written in Java code to implement a simple Swing UI As an experiment the same Swing user interface has been written as a JellyScript as well. While this is a fairly simple Swing UI and not a particularly great example of the power of JellySwing, it does highlight the main difference between the two appraches.