<b>(a)</b> skij> (define button (new 'java.awt.Button "Press Me")) <<< #<java.awt.Button[button0,0,0,0x0,invalid,label=Press Me]> <b>(b)</b> skij> (invoke button 'setLabel "Please Press Me") skij> (define window (new 'java.awt.Frame)) <<< #<java.awt.Frame[frame1,0,0,0x0,invalid,hidden,layout=java.awt.Border Layout,resizable,title=]> skij> (invoke window 'setVisible #t) skij> (invoke window 'add button) ;;; Hm, we still can't see anything skij> (invoke window 'getSize) <<< #<java.awt.Dimension[width=112,height=27]> skij> (invoke window 'setSize 300 200) ;;; The window grows, but still we can't see the button! skij> (invoke window 'show) <b>(c)</b> (invoke-static 'java.lang.Thread 'sleep (long 100)) <b>(d)</b> skij> (peek (invoke button 'getSize) 'width) <<< 292 <b>(e)</b> skij> (peek-static 'java.lang.System 'out) <<< #<java.io.PrintStream@3ae82e8c> <b>(f)</b> skij> (define listener (new 'com.ibm.jikes.skij.misc.GenericCallback (lambda (event) (print "That tickles!")))) <<< #<com.ibm.jikes.skij.misc.GenericCallback@8bbc2e8c> skij> (invoke button 'addActionListener listener)
Example 1: Scheme primitives and examples. (a) Arguments; (b) invoke; (c) invoke-static; (d) peek; (e) peek-static; (f) applying a procedure to an event. In these interactive examples, "skij>" is the prompt, what follows is typed by users. If a value is returned, it is printed after "<<<." Java objects that are not standard Scheme types are quoted with the "#<...>" notation.