Skip to content

Instantly share code, notes, and snippets.

@daveray
Created August 31, 2012 01:56
Show Gist options
  • Save daveray/3547722 to your computer and use it in GitHub Desktop.
Save daveray/3547722 to your computer and use it in GitHub Desktop.
Clojure/Seesaw busy cursor example
(ns busy-cursor.core
(:use seesaw.core))
(defn long-running-task
[]
(Thread/sleep 5000)
"The result")
(defn run-task-with-busy-cursor
[c]
(config! c :cursor :wait)
(future
(let [result (long-running-task)]
(invoke-later
(text! (select c [:#result]) result)
(config! c :cursor :default)))))
(defn -main
[& args]
(invoke-later
(let [c (border-panel :north (label :id :result :text "Nothing Yet")
:center (button :id :click-me :text "Click Me"))
f (frame :title "Busy busy busy" :content c :on-close :exit)]
(listen (select f [:#click-me])
:action
(fn [_]
(run-task-with-busy-cursor c)))
(pack! f)
(show! f))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment