NestedSwinger translates a simple GUI textual notation into a Java application. The notation is considerably easier to write than Java GUI code since it hides details about GUI component initialization, layout managers, and listener code. It does this by treating a GUI as a series of widgets inside nested containers.
The generated Java code is simple to read and change because the NestedSwinger translation restricts itself to using basic GUI controls, standard layout managers, simple listener methods, all formatted to be human-readable.
NestedSwinger isn’t the last word in automatic GUI creation. It’s aimed at quickly prototyping fully functioning GUIs employed by novice or intermediate Java users. In particular, the programmer will need to edit the resulting listener code to add or change features.
Let’s assume that we need to create a GUI application for controlling a printer, which has to look something like the drawing on the right.
The NestedSwinger manual explains at length how to write down this drawing as a textfile of nested containers and widgets. The resulting NestedSwinger GUI text is:
border { center: vbox { label "Printer: LP001" flow { vbox { checkbox "Image" checkbox "Text" checkbox "Code" } vbox { radio "Selection" group=g1 radio "All" on group=g1 radio "Applet" group=g1 } } flow { label "Print Quality: " popdown { "High" "Medium" "Low" } checkbox "Print to File" } } east: grid 4 1 { button "Ok" button "Cancel" button "Setup..." button "Help" } }
The manual describes the details of the syntax, but the containers in this example are
border
, flow
, vbox
, and grid
, with
their nesting represented by {...}
blocks.
The widgets used inside these containers are label
, radio
,
checkbox
, popdown
, and button
.
The NestedSwinger translator generates a Java file for this text, which, when compiled and run, produces the GUI application shown on the right. Clicking on the various components produces short textual output, that is sent to stdout