7.16. OTHER COMMON ACTIONS
93
(readexprlist COMPONENT) reads the text on a component as a se
quence of Scheme terms and returns a list containing those terms
(writeexpr COMPONENT OBJ) convert the object to a string and write
on the component
(writelnexpr COMPONENT OBJ) same as above, but add a new line at
the end
(appendexpr COMPONENT OBJ) append the stringified object to the text
on the component
(appendlnexpr COMPONENT OBJ) same as above, but add a newline at
the end
7.16
Other Common Actions
(.hide COMP) (.show COMP) hiding or showing a component (or win
dow)
(.pack WIN) (.resize WIN ROWS COLS) resizing a window
(.setForeground COMP COLOR) (.setBackground COMP COLOR)
(.setFont COMP FONT)
(.addMouseListener COMP
(Listener.
(lambda(e) (let ((x (.getX e)) (y (.getY e))) ...))))
(.addMouseMotionListener COMP
(Listener.
(lambda(e) ...)))
(.fillRect (.getGraphics g) x y w h)
(.fillRect (.bufferg$ CANVAS) x y w h)
(.repaint CANVAS) canvas objects have an associated backbuffer which
you can access using (.bufferg$ CANVAS).
7.17
Reactive Programs
We now describe a whole class of applets that can be written without requiring
a great deal of programming. These are the programs which create a graphical
user interface in which each action consists of some small number of primitive
operations. For example,
read from some textfields, use the values to compute some other values,
and write those in other textfields, or
pop up a window containing a description of the program, or