James Williams
LinkedInMastodonGithub

Groovy SwingXBuilder Demo

Tags: SwingX

This is an reasonable approximation of the Painter Demo implemented using my Summer of Code project, the Groovy SwingXBuilder. It's not a pixel perfect port since I used a different LayoutManager, namely MigLayout. The amount of options makes it a little overwhelming at first but I found it easy to tweak components.

Note: This is a WIP and thus not feature complete. Not ready for prime time yet.

Painter Demo Photo

This is not the full Painter demo. The glowing shield and wooden area are images. The following code shows how the compound painter was constructed for the header panel:

def compoundPaint = swing.compoundPainter() {
    mattePainter(fillPaint:new Color(51,51,51))
    pinstripePainter(paint:new Color(1.0f,1.0f,1.0f,0.17f),spacing:5.0f)
    glossPainter(paint:new Color(1.0f,1.0f,1.0f,0.2f),position:GlossPainter.GlossPosition.TOP)
}

Using the builder cut down the lines of code from 441 lines in the Java version to 127 in the Groovy version. Most of that reduction comes from combined declaration and layout.

Download the Netbeans project here.