Posts from August 2007

SwingXBuilder FAQ

Posted

Today was the official end of coding for my Google Summer of Code project. For those who haven’t been following my progress, here are the quick points you should know.

What is it?
SwingXBuilder is to Swing as SwingBuilder is to Swing. It provides a means to build a user interface using a hierarchical tree based structure.

Why did you make it?
It was sponspored by Google for the Google Summer of Code 2007. The official coding period ends on August 20, 2007.

Is there anything special I need to do to my user interfaces to port them from SwingBuilder to the SwingXBuilder?
For the most part no. All Swing components are available in SwingXBuilder. For the components that have SwingX versions, you will have to use the property classicSwing to use the Swing version.

Sounds cool. Where can I see some demos?
Painter Demo Webstart
Calendar Demo Webstart
30Boxes Viewer Blog Entry (requires an api key and auth token from 30Boxes)
The full source is included in the Subversion tree.

What about documentation?

Check out http://groovy.codehaus.org/SwingXBuilder.

Is it being used in production applications?
Yes. In July, I ported a Java console application for my 9-5 to Groovy using SwingXBuilder to make the interfaces.

Using classic Swing components with SwingXBuilder

Posted

Because they aren't core Java, the mileage really varies when it comes to how SwingX components will be drawn in different Look and Feels. For some components, like JXButton, I didn't find myself often using any of the SwingX capabilities anyway. Sometimes I really want just a JButton instead. Because the new Button Factory replaced the old one, I would have to use a combination of another SwingBuilder object and the widget node in a somewhat contrived manner:


def swing = new SwingBuilder()
def swingx = new SwingXBuilder()
def frame = swingx.frame(size:[300,300]...) {
    	label(text:'Hi')
    	widget(swing.button(text:'Click me'...))
}.show()



Add an actionPerformed closure and it makes for a very ugly and hacky line.

Enter the "classicSwing" attribute


The classicSwing attribute is new to SwingXBuilder and takes a boolean value. If it is set to true, SwingXBuilder attempts to create the node using a member instance of plain old SwingBuilder, otherwise it executes the createNode function using the updated factory map. The above Groovy code is now:

 
def swingx = new SwingXBuilder
def frame = swingx.frame(size:[300,300]...) {
    	label(text:'Hi')
    	swing.button(classicSwing:true, text:'Click me'...))
}.show()


Aaaah, much more clean and concise.

SwingXBuilder update Documentation fun

Posted

As the GSoC runs down[it ends this month], in an effort to get stuff done, one often puts off the mundane tasks(i.e. documentation) until later. Well, now is the time to start. I’ve been updating the Groovy wiki with snippets, attributes and types. Hopefully this will help folks to port their stuff to SwingX when the builder goes into production.