wl

Unnamed repository; edit this file 'description' to name the repository.
git clone https://logand.com/git/wl.git/
Log | Files | Refs | LICENSE

swing5.l (907B)


      1 (load "swing.l")
      2 
      3 (setq W (jnew JFrame "Celsius Converter"))
      4 (setq L (jnew JTextField))
      5 (setq C (jnew JLabel "Celsius"))
      6 (setq B (jnew JButton "Convert"))
      7 (setq F (jnew JLabel "Fahrenheit"))
      8 
      9 # (de b (E)
     10 #    (let X ((jclass 'java.lang.Double) 'parseDouble (L 'getText))
     11 #       (F 'setText (pack (+ 32 (* 2 X)) " Fahrenheit")) ) )
     12 # #      (F 'setText (pack (+ 32 (* 1.8 X)) " Fahrenheit")) ) )
     13 
     14 (de b (E)
     15    (job '((L . `L) (F . `F))
     16 #      (let X (`(jclass 'java.lang.Double) 'parseDouble (L 'getText))
     17       (let X (jnum (L 'getText))
     18          (F 'setText (pack (+ 32 (* 2 X)) " Fahrenheit")) ) ) )
     19 #      (F 'setText (pack (+ 32 (* 1.8 X)) " Fahrenheit")) ) )
     20 
     21 (B 'addActionListener (jproxy NIL 'b ActionListener))
     22 (W 'setDefaultCloseOperation (jfield JFrame 'EXIT_ON_CLOSE))
     23 (W 'setLayout (jnew GridLayout 2 2 3 3))
     24 (W 'add L)
     25 (W 'add C)
     26 (W 'add B)
     27 (W 'add F)
     28 (W 'setSize 300 80)
     29 (W 'setVisible true)