Source

neman / examples / swing1.clj

(ns user
  (:import
    (java.awt BorderLayout)
    (javax.swing JFrame JButton))
  (:use
    (net.ksojat.neman
      core
      [swing :only [swing doswing]])))

(defn run-it []
  (swing
    (=> ~frame (JFrame. "Example")
      :Layout (BorderLayout.)
      :Size [300 200]
      :DefaultCloseOperation JFrame/DISPOSE_ON_CLOSE

      ~@(println frame)

      [(=> ~button1 (JButton. "Button1")
         :LayoutData BorderLayout/WEST
         (>> :actionPerformed
           (fn [e]
             (.setText button2 "Changed")
             (.setText button1 "Button1"))))

       (=> ~button2 (JButton. "Button2")
         :LayoutData BorderLayout/EAST
         (>> :actionPerformed
           (fn [e]
             (.setText button1 "Changed")
             (.setText button2 "Button2"))))])))

(doswing
  (.setVisible (run-it) true))