A Clojure library designed for your application to add desktop alert easily.
logutil is available in Clojars.org. Your leiningen project.clj:
Please read API document.
Old style:
(def frm (JFrame.))
(def sz (Dimension. 240 60))
(def duration 1000)
(def content (doto (JPanel.) (.add (JLabel. "Alert!"))))
(init-alert frm (.getWidth sz) (.getHeight sz) :rl-bt 1 200 (float 0.9) nil) ;; init alerter
;;(init-alert frm capacity (.getWidth sz) (.getHeight sz) :rl-bt 1 200 (float 0.9) nil) ;; fixed capacity queue
(alert content duration) ;; display alert during 1000 milliseconds. content is a java.awt.Component or subclass.
(close-alert) ;; close alerter.
New style:
(require '[clojure.core.async :as ca])
(def frm (JFrame.))
(def sz (Dimension. 240 60))
(def duration 1000)
(def content (doto (JPanel.) (.add (JLabel. "Alert!"))))
(let [[ach ar] (init-alert frm (.getWidth sz) (.getHeight sz) :rl-bt 1 200 (float 0.9) nil)] ;; init alerter
(ca/>!! ach {:cmd :alert :content content :duration duration})
(ca/close! ach) ;; close the alerter control channel.
(ca/<!! ar)) ;; wait the alerter go routine is finished.
Copyright (C) Shigeru Fujiwara All Rights Reserved.
Distributed under the Eclipse Public License, the same as Clojure.