X

Geertjan's Blog

  • September 24, 2009

Another Look at the Visual Library as Form Builder

Geertjan Wielenga
Product Manager
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>
<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"/>
</file>
</folder>

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:

http://kenai.com/projects/org-simple-editor

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

Join the discussion

Comments ( 1 )
  • Toni Epple Thursday, September 24, 2009

    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.

    --Toni


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.