7.2. OVERVIEW OF THE JLIB TOOLKITS
83
and determines the precise minimum size of the window so that everything just
fits inside it. The (.show win) command makes the window appear.
Although this little program does quite a bit (requiring a paragraph to de
cide), the code for the program is relatively concise. Each word that appears
in the program has a particular effect (except for the lambda(e) which we will
explain later). By replacing col with row we would get a horizontal layout, and
by replacing label with button our greeting would be able to take an action.
7.2
Overview of the JLIB toolkits
The key idea of the JLIB toolkit is to use the flexibility and expressiveness
of Scheme to create a GUI building library which allows complex GUIs to be
built by evaluating a simple and declarative expression whose structure closely
resembles the structure of the GUI itself.
The JLIB model is based on five fundamental concepts:
COMPONENTS there are a small number of ways to construct basic
components (buttons, windows, ...)
LAYOUTS there are a small number of ways to layout basic components
(row, col, table, grid, ...)
ACTIONS there is a simple mechanisms for associating an action to a
component
PROPERTIES there are easy ways for setting the font and color of
components
TAGS this is a mechanism for giving names to components while they
are being laid out.
Another key idea is that operations on all components should be as uniform
as possible. For example, there are procedures readstring and writestring
which allow one to read a string from a component, and write a string onto
a component. Thus writestring can change the string on a label, a button, a
textfield, a textarea. It can also change the title of a window or add an item to
a choice component. Likewise, readstring returns the label of a button, the text
in a textarea or textfield, the text of the currently selected item in a choice, the
title of a window, and the text of a label.
Similarly, JLIB is designed so that the component and layout constructors
require a few initial arguments of specified types, followed by many optional
arguments which may apper in any order and whose types are used to determine
their effect.
For example, a font object will change the font of the component, a color
object will change the background color, a Listener object will add an action
listener to the component, a string will generally become the label of the object.
We introduce each of these components in turn. As we go through these
examples you should try them out yourself in a Jscheme interpreter window.