## 桌面應用
Clojure 可以創建基于Swing的GUI程序。下面是一個簡單的例子, 用戶可以輸入他們的名字,然后點擊“Greet:按鈕,然后它會彈出一個對話框顯示一個歡迎信息。可以關注一下這里我們使用了 `proxy` 宏來創建一個集成某個指定類 ( `JFrame` )并且實現了一些java接口 (這里只有 `ActionListener` 一個接口)的對象。.
 
```
(ns com.ociweb.swing
(:import
(java.awt BorderLayout)
(java.awt.event ActionListener)
(javax.swing JButton JFrame JLabel JOptionPane JPanel JTextField)))
(defn message
"gets the message to display based on the current text in text-field"
1
(str "Hello, " (.getText text-field) "!"))
; Set the initial text in name-field to "World"
; and its visible width to 10.
(let [name-field (JTextField. "World" 10)
greet-button (JButton. "Greet")
panel (JPanel.)
frame (proxy [JFrame ActionListener]
[] ; superclass constructor arguments
(actionPerformed [e] ; nil below is the parent component
(JOptionPane/showMessageDialog nil (message name-field))))]
(doto panel
(.add (JLabel. "Name:"))
(.add name-field))
(doto frame
(.add panel BorderLayout/CENTER)
(.add greet-button BorderLayout/SOUTH)
(.pack)
(.setDefaultCloseOperation JFrame/EXIT_ON_CLOSE)
(.setVisible true))
; Register frame to listen for greet-button presses.
(.addActionListener greet-button frame))
```