JRBuilder (SwingBuilder) and Bindery Home Page
Examples      Download Examples      Download

JRBuilder: A SwingBuilder for JRuby, with Binding

Update: 9 June 2007: At long last, the first beta version of Cheri, the successor to JRBuilder, has been released. You can download it from its new home at RubyForge, or just type
   gem install cheri
at the nearest command prompt. In addition to Cheri::Swing, the module that supersedes JRBuilder, Cheri includes Cheri::Html and Cheri::Xml, as well as a tool for building builders, and a JRuby runtime browser, Cheri::JRuby::Explorer, written using Cheri::Swing and Cheri::Html. Whew! I hope it will prove worth the wait. This is a beta release (version 0.0.2), but the Cheri::Swing component is pretty stable. Documentation will be up at the site in the next 24 hours.

Update: 6 Mar 2007: JRuby 0.9.8 has been released! Get it now at the download page.

I ended up incorporating pretty much all of the extended Java array features from my Cheri Java preview into JRuby 0.9.8 itself, though in a slightly different form. Cheri remains the new name of the JRBuilder/Bindery project, but I've been too busy the past few weeks to get new features out. Once I wrap up one more project for JRuby (a new and improved sprintf), I'll get back to it, so stay tuned to this space and the Cheri page!

Update: 14 Feb 2007: Ongoing development of JRBuilder will now move to my Cheri project. Though release of all Cheri components is still a week or two away, a Java array component has been released. See the Cheri Project page for details!

After seeing several posts on the jruby-user and jruby-dev newsgroups in December about a future Groovy-like SwingBuilder application for JRuby, I decided to take a crack at it. The result is the JRBuilder module (and the related module Bindery, also inspired by some posts on the JRuby newsgroups). The JRBuilder::SwingBuilder class aims to provide functionality similar to Groovy's SwingBuilder. On the surface, at least, the result looks fairly similar, but I confess I really haven't had a chance to delve into Groovy's offering in depth. The Groovy SB may well offer features I haven't seen yet.

Either way, there are certainly many more features I'd like to add to JRBuilder (and Bindery, which I'll discuss in a moment). But the time has come to start getting feedback from real users, before I stray onto the path of pointless development.

With that, I offer you the first public release of JRBuilder, version 0.1.0. [Download] (zip, nnK)

The included (and required) Bindery module aims to provide simple data binding, in the spirit of JSR 295 ("Beans Binding"), if not in its methods. There are many more features I'd like to add to Bindery, as well (support for lists, tables, and so on, for starters). But again, I think now is the time get a feel for what people need and want the most in data binding.

I recommend you browse through the example pages, in most of which I keep a running commentary alongside the code. It's the closest thing I have to documentation right now. There are some comments in jrbuilder.rb, though already some of them are out of date (sheesh, I only started this project a little over a month ago). There are virtually no comments in bindery.rb, which I banged out late nights in a caffienated frenzy.

I welcome (and would appreciate) any and all of your comments, suggestions, corrections, bug reports, feature requests, and so on. My email address is in the README and in the modules.

Bill Dortch
30 January 2007

require 'jrbuilder'

ctx = JRBuilder.new_swing_context
ctx.enter {
  attr_reader :my_frame

  @my_frame = frame('Hello World Demo 1') { size 320, 240
    content_pane { layout :box,_parent,:Y_AXIS }
    on_window_closing { my_frame.dispose }
    menu_bar { 
      menu('File') {  mnemonic :VK_F; background :WHITE
        menu_item('Exit') { mnemonic :VK_X; background :WHITE
          on_click { my_frame.dispose }
        }
      }
    }
    y_glue
    panel {layout :box,_parent,:X_AXIS; background :WHITE 
      label('Hello, World!') {  foreground :BLUE }
    }
    y_glue
  }
}

ctx.my_frame.show
Examples      Download