Matthew Wong
631
HW 4
Interface Builder

To compile: use the command line

> javac *.java

To run:

> java IB

I built it on a Microsoft Windows platform.

I developed a simple Interface Builder, per the specifications under
"Project Alternative 1".  My Interface Builder works with Buttons,
Labels, Radio Buttons, Checkboxes, and Vertical Sliders.  It also
works with no layout, Flow Layout, Border Layout, Box Layout, and Grid
Layout.  I did not implement Grid Bag Layout.

Examples

There are 7 examples in the examples folder.  Each example contains
the .tib file and also the generated .java file.  The .tib file is the
text file used to save the state of the interface.

FlowExample.java - FlowLayout Example
BorderExample.java - BorderLayout Example
BoxHorizontalExample.java - Box Example (Horizontal)
BoxVerticalExample.java - Box Example (Vertical)
GridExample.java - GridExample
RadioGroupExample.java - Example which shows multiple ButtonGroups
Calculator.java - Example which highlights Callback - a power of 2 calculator

Brief Documentation:

I tried to design the interface so any moderate computer user could
walk up and use it.  There are 3 internal frames.  There is a Menu
Frame, a Properties Frame, and a Form Frame.

Menu Frame

In the Menu Frame, the UI Designer can pick the layout, clear the
interface, clone widgets (i.e. make an identical copy of the selected
widget), or add new widgets.  There are 6 modes: 1 mode for each type
of widget, and a sixth mode, which is "Select Mode".  When the Menu
state is in "Select Mode", pressing the mouse on the Form will not
create a new widget.  The main purpose of this feature is so that the
designer can shift the focus to the background of the Form Frame.

Properties Frame

The Properties Frame is a dynamic JTable.  There are two columns:
Parameter and Value.  When the designer shifts the focus to a widget
in the Form Frame, the Properties Table gets populated with that
widget's properties.  The designer can then edit the "Value" column
for the desired Parameter.  Note that there is limited error checking;
for instance, the Interface Builder doesn't check to make sure the
designer enters in valid Java code for the Callback properties.  It
does however make sure that widths and heights are entered as valid
numbers.  The coordination between the Properties Table and the
widgets in the Form Frame are automatically synchronized with the help
from an abstract class called "Modifier".  This class represents the
relationship between a widget and the data in the Properties Table.
This "Modifier" model is very similar to Interactors.

Form Frame

The Form Frame is where the designer can draw his widgets with the
mouse by clicking and dragging.  The frame itself can be resized, and
this will have an effect in the generated code as well.  When there is
no layout, the designer is free to draw the widgets' boundaries with
the mouse.  In the layout modes, the easiest way (and often the only
way) to create widgets is through the "Add New Widget" button in the
Menu Frame.  The designer can move objects by clicking on them and
dragging them (only when there is no layout).

The designer can right click on a widget, to bring up a context popup
menu.  Through this menu, he can delete a widget, as well as rearrange
the widget orderings in layout modes, or raise and lower widgets in
"no layout" mode.

There is an idea of "Handles" in this Interface Builder.  The
handle is really just a purple Border around the widget.  These
handles provide a visible boundary around the widgets, and they also
allow the designer to resize the widgets, after they are already
create.  The designer can turn off the handles in the checkbox in the
Menu Frame.  Since widgets can't be resized in a layout mode, handles
are never displayed if there is a predefined layout.  Note that these
handles will not be displayed in the generated Java code.  They are
only present in the Interface Builder to aid the designer.

When the designer is finished with the interface, he can save his work
by going to the File menu, and selecting either "Save" or "Save As".
The standard is to save it with an extension ".tib".  These .tib files
are text files which represent the created widgets.  At a later point
in time (even after the Interface Builder is closed), the designer can
open this ".tib" file and be back in the same state when it was saved.

Finally, there is the ability to export the interface into Java code.
The designer picks "File | Export .java file" from the pull down menu,
and selects the filename.  Note that this also implicitly selects the
class name.  The code is then generated and saved in this file.  At
that point, the designer can compile and run the code.

