make-action(clojure.contrib.swing-utils)

Create an Action proxy from the given action spec. The standard keys recognised are: :name, :accelerator, :command-key, :long-desc, :short-desc, :mnemonic and :icon - corresponding to the similar named Action properties. The :handler value is used in the actionPerformed method of the proxy to pass on the event.

; clojure/contrib/swing_utils.clj:80
(defn make-action
  [spec]
  (let [t-table @action-translation-table
        handler (:handler spec)
        spec    (dissoc spec :handler)
        spec    (map (fn [[k v]] [(t-table k) v]) spec)
        action  (proxy [AbstractAction] []
                  (actionPerformed [evt] (handler evt)))]
    (doseq [[k v] spec]
      (.putValue action k v))
    action))

Copyright (c) Rich Hickey. All rights reserved.

The use and distribution terms for this software are covered by the Eclipse Public License 1.0, which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.