swing4.l (994B)
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 BorderLayout)) 24 (W 'add L (jfield BorderLayout 'NORTH)) 25 (W 'add C (jfield BorderLayout 'WEST)) 26 (W 'add F (jfield BorderLayout 'EAST)) 27 (W 'add B (jfield BorderLayout 'SOUTH)) 28 (W 'pack) 29 (W 'show)