82 CHAPTER 7. GRAPHICAL USER INTERFACE DESIGN IN SCHEME
"Greeting"
"Tim Hickey"
"http://www.cs.brandeis.edu/~tim"
"This pops up a greeting window"
"http://www.cs.brandeis.edu/~tim/hickey.new.gif"
(jlib.JLIB.load)
(define win
(window "hello"
(col
(label "Greetings"
red
(HelveticaBold 60)
(button
"goodbye"
(action (lambda(e) (.hide win))))))))
(.pack win)
(.show win)
Figure 7.1: hello.applet
If you change the filename from hello.applet to hello.snlp, and if you
have installed the Java Web Start plug in
1
then the browser will download the
program as a Java Web Start application and it will again pop up a window as
before. The difference with Java Web Start is that the next time you visit that
link, the browser will only download the program if there has been a change in
the code. If not, then it will use the version it has stored on your disk. Moreover,
you can disconnect your computer from the net and still run the stored copy of
the program.
The program if Figure 7.1 illustrates a number of features of the JLIB toolkit.
First, observe that it defines three components:
a label
a button, and
a window.
Each of these components has a string written somewhere on it ( Greetings ,
goodbye , and hello respectively). The label has also been given a specified
color and font, and the button has been given an action. The relative position
of the label and button has been specified by the col layout procedure, which
states that the label and button should appear in a column. Finally, the
action on the button causes the window to disappear when the button is
pushed. The last two commands are (.pack win) which does the window layout
1
http://java.sun.com/products/javawebstart