« August 2007 | Main | October 2007 »

September 2007 Archives

September 25, 2007

New and Mildly Entertaining features in SwingBuidler

There have been some big back end changes going on in the SwingBuilder to support some fairly mild but useful features. With exciting things like bind() and animate() they can get lost in the mix. Here are some New and mildly Entertaining features in Groovy's SwingBuilder (note that some of these have shown up after Beta-3, so snapshots are still the best place to go until the despots start rolling relese candidates).

  • the widget() node has two new friends -- container() and bean()
    The intent is that JComponents that contain other components use container(), standalone JComponents use widget (and are prohibited from having any child content) and non-JComponents use bean() (but this is not yet enforced). Why would you want non-components in the swing builder? bind() and animate() are two reasons.
  • actions() node -- a place to make actions
    it's actually just going to return a list of all child nodes in it, assuming you are going to do anything with the list. Console uses it to pack all of the data into it's many actions.
  • SwingBuilder.build() static method -- in the EDT no less!
    This creates a new SwingBuilder, and calls the closure inside of the Event Dispatch Thread (EDT) and waits for it. Which all good Swing programmers know (and mostly ignore) that you are supposed to create JComponents in the EDT. The SwingBuilder that is used for the calls is returned
  • dispose() method -- it's cleanup time everyone!
    Keeping track of your windows and such can be hard enough, now with bindings attaching listeners there is more clean up to do. All of the cleanup such as removing listeners and disposing JFrames is called when you call dispose().
  • pack: and show: attributes -- for window, frame and dialog
    I always thought it was kinda strange that you would use a builder, then have to pack and show your frames outside the builder. Now you can do both declaratively! pack() and show() setVisible(true). (show() is deprecated, remember?)
  • edt, doLater, and doOutside closure methods -- because invokeAndWait is too many keystrokes.
    Each of these calls SwingUtilities.invokeAndWait, SwingUtilities.invokeLater, and new Thread(closure).start() respectivly. Because SwingUtilities.invokeLater() is too much typing, and importing. As is EventQueue.invokeLater, whatever package that one is in.
  • model() node -- automatic binding
    This is deserving of a blog post of it's own, but a dev list posting should give you an idea.

Given that Groovy 1.1 is going to ship here in the next month or so, not too much exciting stuff will likely get added, but I am not the best at following build protocol at my day job, so who knows.

About September 2007

This page contains all entries posted to ... And They Shall Know Me By My Speling Errors in September 2007. They are listed from oldest to newest.

August 2007 is the previous archive.

October 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.33