Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

JFrame, inner defs

By: a guest on Nov 10th, 2011  |  syntax: Clojure  |  size: 1.24 KB  |  views: 97  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (def top-frame
  2.   (doto (Frame.)
  3.     (.addWindowListener
  4.      (proxy [WindowAdapter] []
  5.        (windowClosing [e] (.dispose top-frame))))
  6.     (.add (doto @(def top-panel (Panel.))
  7.             (.setLayout (BorderLayout. 5 5))
  8.             (.add "North" (doto @(def choice (Choice.))
  9.                             (.add "None")
  10.                             (.addItemListener
  11.                              (reify ItemListener
  12.                                (itemStateChanged [_ e]
  13.                                  (send timers change-timer (.getItem e))
  14.                                  (.validate top-panel))))))
  15.             (.add "Center" (doto @(def timer-panel (Panel.))
  16.                              (.setLayout (GridLayout. 0 2))))
  17.             (.add "South" (doto (Panel.)
  18.                             (.setLayout (GridLayout. 0 2))
  19.                             (.add (doto (Button. "Add")
  20.                                     (.addActionListener
  21.                                      (reify ActionListener
  22.                                        (actionPerformed [_ _]
  23.                                          (add-timer (.getText add-name)))))))
  24.                             (.add @(def add-name (TextField.)))))))
  25.     (.pack)
  26.     (.setVisible true)))
  27.