Another Look at the Visual Library as Form Builder

I've heard some disparaging comments about using the Visual Library as a form builder, which I showed is possible a few days ago. You'd be surprised, though, at how much functionality the Visual Library offers for composing forms. Sure, not GroupLayout-like resize/repositioning. But, take a look at this:

The widgets can be aligned with each other (and they can be resized), which is a typical feature one would expect in a form builder. Maybe not everything one would ever want, as in Matisse, could be supported, but not every form builder needs all of those features.

And, unlike Matisse, the editor above has "Print" support! I.e., you can lay out your form and then invoke the Print menu item in the application... and then you'll see a preview and then you'll be able to print it. (In fact, that's literally one line of code in my TopComponent.)

Interesting detail in my implementation is that new beans are put in the Palette from the outside like this:

<folder name="AWidget">
    <file name="org-simple-editor-beans-SimpleBean.instance">
        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.simple.editor.Bundle"/>
        <attr name="component" newvalue="org.simple.editor.beans.SimpleBean"/>
        <attr name="type" bundlevalue="org.simple.editor.Bundle#TYPE_SimpleBean"/>
        <attr name="text" bundlevalue="org.simple.editor.Bundle#TEXT_SimpleBean"/>
        <attr name="length" intvalue="200"/>
        <attr name="height" intvalue="80"/>
        <attr name="icon" stringvalue="/org/simple/editor/resources/simple.png"/>
    <file name="org-simple-editor-beans-Ticker.instance">
        <attr name="SystemFileSystem.localizingBundle" stringvalue="org.simple.editor.Bundle"/>
        <attr name="component" newvalue="org.simple.editor.beans.Ticker"/>
        <attr name="type" bundlevalue="org.simple.editor.Bundle#TYPE_Ticker"/>
        <attr name="text" bundlevalue="org.simple.editor.Bundle#TEXT_Ticker"/>
        <attr name="length" intvalue="200"/>
        <attr name="height" intvalue="80"/>
        <attr name="icon" stringvalue="/org/simple/editor/resources/ticker.png"/>

So long as the "component" attribute refers to a JComponent, it will be added to the Palette and work correctly when drag/dropped into the scene. The related properties then appear in the Properties window when the widget is selected. Two-way editing is supported, to the extent that the bean makes that possible.

Get the sources from Subversion here:

I'm working on the serialization at the moment. That doesn't work correctly yet.


Hi Geertjan, that's cool, did you get the plugin I sent you to work? I did some experiments with Swing and Vislib a while ago: With swing components you can even very easily add baseline support to align the text instead of the components.


Posted by Toni Epple on September 24, 2009 at 03:50 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« June 2016